Typo3 custom content with 2 headers - typo3

I am trying to create a new content element (not sure if its the correct name for it) and i want to achieve something like this
HEADER_1
HEADER_2
body text
in my tt_content.php file i have the following:
'showitem' => '
--div--;Intro,
--palette--;LLL:EXT:/path/to/locallang_ttc.xlf:palette.general;
general,
header,
bodytext,
module_background_color,
--palette--;;cta,
I tried to add something like this
'showitem' => '
--div--;Intro,
--palette--;LLL:EXT:/path/to/locallang_ttc.xlf:palette.general;
general,
header,
header,
bodytext,
module_background_color,
--palette--;;cta,
or this
'showitem' => '
--div--;Intro,
--palette--;LLL:EXT:/path/to/locallang_ttc.xlf:palette.general;
general,
header,
bodytext,
bodytext,
module_background_color,
--palette--;;cta,
both didnt work and i can only get 1 header and 1 body text, i am so new to this and somehow i need to do it
p.s i can't do it via 1 header because every header has its own styling.
Thanks

One column can only be used once!
Take an look in the header element. Here you can see an column named subheader.
so following should add another header column:
'showitem' => '
--div--;Intro,
--palette--;LLL:EXT:/path/to/locallang_ttc.xlf:palette.general;
general,
header,
subheader,
bodytext,
module_background_color,
--palette--;;cta,

Related

TYPO3 new tab to custom extension

I write my own extension. I have the file tx_xyz_domain_model_abc.php
with following code:
'types' => [
'1' => [
'showitem' => '
--div--;Article, title,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language, sys_language_uid, l10n_parent, l10n_diffsource,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, hidden, starttime, endtime,
'],
],
so the first line is my new field. The other lines are TYPO3 defaults. A --div-- is a new tab. How can i add the media or general tab to my extension?
I've tried to add
--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
But there is no new tab. How can i do this?
--palette--; will insert a new palette (=grouped fields) to the current tab (-> TCA ref).
Without defining a tab, the fields are automatically put in a "General"-Tab at first position.
'types' => [
'0' => [
'showitem' => '
hidden, title,
--div--;LLL:EXT:examples/locallang_db.xml:tx_examples_product.images, image1, image2,
'
],
],
For further tabs, you need to insert a "--div--;label"-value in the field list (-> TCA ref):
'types' => [
'0' => [
'showitem' => '
hidden, title,
--div--;LLL:EXT:examples/locallang_db.xml:tx_examples_product.text, description, teaser,
--div--;LLL:EXT:examples/locallang_db.xml:tx_examples_product.images, image1, image2,
'
],
],
To show the core general tab in your extension is not possible. You wrote your own extension with your own data model. This is saved in db table tx_xyz_domain_model_abc. But data in core are from table tt_content which has a separate TCA.
You can
Extend table tt_content with your extension. Then you can use fields from tt_content
Add fields like header in your extension and table

Is it possible to remove the 'Delete' and 'Add x' on the 'table' field for Laravel Backpack?

I'm currently setting up a backpack CRUD for languages/translations, and I'd like the translations to be bulk editable from the language CRUD. I've currently got that working through the update operation like so:
protected function setupUpdateOperation()
{
$this->setupCreateOperation();
CRUD::addField([
'name' => 'translations',
'label' => 'Translations',
'type' => 'table',
'entity_singular' => 'translation',
'columns' => [
'key' => 'Key',
'text' => 'Text'
]
]);
}
Which looks like this:
preview image
The problem I'm running into here is that all the 'keys' should be static (but still displayed), as well as that users shouldn't be able to 'add' translations or remove them. (Translation creation is handled by setting up default translations each time a language is created)
Is it possible to
Make it so that the 'key' column is uneditable but still displayed.
Remove the 'Add translation' button at the bottom of the table.
Remove the 'Delete' trashcan icon at the end of each translation line
Many thanks in advance!
Add these lines to your Controller. You can add it anywhere but I prefer to add in public function setup()
$this->crud->denyAccess('delete');
$this->crud->denyAccess('create');
However user cannot add Translation but this will not remove the + Add Translation button. So to remove that button also,
remove this line
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
Sources:
https://github.com/Laravel-Backpack/CRUD/issues/257
https://backpackforlaravel.com/docs/4.1/crud-operation-show

Adding new checkbox field to tx_news_domain_model_media

I am trying to add a new checkbox field 'showinhome' to the table 'tx_news_domain_model_media' same to the field 'showinpreview' here is my TCA Configuration in Configuration/TCA/Overrides/tx_news_domain_model_media.php
$temporaryColumns = [
'showinhome' => [
'exclude' => 1,
'label' => 'Show in Home',
'config' => [
'type' => 'check',
'default' => 0,
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tx_news_domain_model_media',
$temporaryColumns
);
$GLOBALS['TCA']['tx_news_domain_model_media']['ctrl']['label_alt'] .= ', showinhome';
$GLOBALS['TCA']['tx_news_domain_model_media']['interface']['showRecordFieldList'] .= ', showinhome';
$GLOBALS['TCA']['tx_news_domain_model_media']['palettes']['newsPalette']['showitem'] .= 'showinhome,';
The field is not displayed, can someone help me please?
You have mixed up some stuff here.
First: tx_news can use either the own media model or the native FAL relations. I personally always use the native FAL relation.
If you want to add this field to the media table, then there is no newsPalette there. You can use the below code to add the new field:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tx_news_domain_model_media', $temporaryColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('tx_news_domain_model_media', implode(',', array_keys($temporaryColumns)));
If you using the normal FAL relation then the showinpreview field is added to the sys_file_reference table's TCA configuration and not to the tx_news_domain_model_media table.
If you want to add this field to the file, then you need to add it to the sys_file_reference field the same way tx_news does it (I guess that you already copied the code from it's override file)
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_reference', $temporaryColumns);
// add special news palette
$GLOBALS['TCA']['sys_file_reference']['palettes']['newsPalette']['showitem'] .= ', showinhome';
Last but not least: you have to specify tx_news as a dependency in your extension, otherwise TYPO3 does not know that your extension has to be loaded after tx_news. If you change the dependency after you installed your extension you probably need to uninstall and install it again in the extension manager.

TYPO3: Use t3lib_TCEforms in frontend plugin

I would like to use as much standard TYPO3 as possible to create a form to edit single records from tx_mytable.
In pi1 i load the tca for the table:
t3lib_div::loadTCA('tx_mytable');
Now I would like to use standard functions to create my form elements more or less like it is done in the backend...
I found this for the front end but cannot find any working examples:
t3lib_TCEforms_fe.php (that extends the normal t3lib_TCEforms)
Is this the right way to go or is there a better way?
I got something working but not really that nice code in the frontend
Here is a link that telss that TCA is not enough but two new entries in the array is needed
http://www.martin-helmich.de/?p=15
It is itemFormElName and itemFormElValue
// include tceforms_fe (place outside class where pipase is included)
require_once(PATH_t3lib.'class.t3lib_tceforms_fe.php');
// load TCA for table in frontend
t3lib_div::loadTCA('tx_ogcrmdb_tasks');
// init tceforms
$this->tceforms = t3lib_div::makeInstance("t3lib_TCEforms_FE");
$this->tceforms->initDefaultBEMode(); // is needed ??
$this->tceforms->backPath = $GLOBALS['BACK_PATH']; // is empty... may not be needed
//////////REPEAT FOR EACH INPUT FIELD/////////
// start create input fields, here just a single select for responsible
// conf used for tceforms similar to but not exactly like normal TCA
$conftest = array(
'itemFormElName' => $GLOBALS['TCA']['tx_ogcrmdb_tasks']['columns']['responsible']['label'],
'itemFormElValue' => 1,
'fieldConf' => array(
'config' => $GLOBALS['TCA']['tx_ogcrmdb_tasks']['columns']['responsible']['config']
)
);
// create input field
$this->content .= $this->tceforms->getSingleField_SW('','',array(),$conftest);
// wrap in form
$output = '<form action="" name="editform" method="post">';
$output .= $this->content;
$output .= '</form>';
// wrap and return output
return $output;
Still looking for a working example with custem template for input fields.

How can I use a local (or per view) variable in Sinatra with Haml partials?

I have a Haml partial in Sinatra to handle all of my 'page open' items like meta tags.
I would love to have a variable for page_title in this partial and then set that variable per view.
Something like this in the partial:
%title #page_title
Then in the view, be allowed to do something like:
#page_title = "This is the page title, BOOM!"
I have read a lot of questions/posts, etc. but I don't know how to ask for the solution to what I am trying to do. I'm coming from Rails where our devs usually used content_for but they set all that up. I'm really trying to learn how this works. It seems like I have to define it and use :locals in some way but I haven't figured it out. Thank you in advance for any tips!
You pass variables into Sinatra haml partials like this:
page.haml
!!!
%html{:lang => 'eng'}
%body
= haml :'_header', :locals => {:title => "BOOM!"}
_header.haml
%head
%meta{:charset => 'utf-8'}
%title= locals[:title]
In the case of a page title I just do something like this in my layout btw:
layout.haml
%title= #title || 'hardcoded title default'
Then set the value of #title in routes (with a helper to keep it short).
But if your header is a partial then you can combine the two examples like:
layout.haml
!!!
%html{:lang => 'eng'}
%body
= haml :'_header', :locals => {:title => #title}
_header.haml
%head
%meta{:charset => 'utf-8'}
%title= locals[:title]
app.rb
helpers do
def title(str = nil)
# helper for formatting your title string
if str
str + ' | Site'
else
'Site'
end
end
end
get '/somepage/:thing' do
# declare it in a route
#title = title(params[:thing])
end