TYPO3 EXT:cart_product: extend backend with one selection to do conditional theming in template - typo3

I'm looking for a way to extend the backend of the TYPO3 extension cart_products with one additional select field. I have already created some different ViewHelpers for the ProductBackendVariants and now need a way to choose the corresponding Viewhelper.
Best would be if there is a selection direct after the type select in the general product type. But I am not able to add some additional configuration fields to this tab.
Already added
'formtemplate' => [
'label' => 'ProductDetail Variant Form',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['Standard', 1],
['Matten', 2],
['Zaunpaket', 3],
],
'size' => 1,
'minitems' => 1,
'maxitems' => 1,
],
],
to the tx_cartproducts_domain_model_product_product.php but nothing appears in the backend.

I don't know that specific extension but some hints in general:
it seems that you have tried to modified the TCA directly in the extension (cart_products/Configuration/TCA/tx_cartproducts_domain_model_product_product.php). You should never change anything in a 3rd party extension (neither the TYPO3 core) because you loose the ability to update.
You need to create your own extension and add a file to Configuration/TCA/Overrides. Ideally you name the file exactly like the file you like to extend for easier understanding. See the documentation for details.
To add a new field to the TCA you not only need to define the name and type but you also need to create the database field. That's done in ext_tables.sql of your custom extension.
It's not sufficent to create the TCA config and SQL mentioned above you also need to tell, where the new field should be visible in the backend. That's done with the showitem setting. See documentation for details.
To ease the process of extending an existing TCA I can recommend the extension TCA Builder which makes it in many cases much easier to create the TCA code. See these examples how that's done. Nevertheless you need to create ext_tables.sql.
Last but not least: when you made changes to ext_tables.sql you need to run the database compare in the TYPO3 install tool.

Related

Change the backend-view of mask - TYPO3

I try - in TYPO3 8.7.13 with the extension mask 3.1.0 - to build for example a CE with repeating records with fields for names - no problem.
But in the backend I can see only the first field. Is there any way to show both?
https://www.dropbox.com/s/rmsg5qfd51blhrf/mask1.png?dl=0
So there are preview templates they belong to the page view and not edit.
In edit mode you only see the label (this is given in the definition of IRRE in the TYPO3 core).
So you only can change the shown 'label' of the record. That means: using label_alt in the TCA (I recommend to use label_alt_force too):
'ctrl' => [
'label' => 'surname',
'label_alt' => 'givenname,surname',
'label_alt_force' => 1,
],

TinyMCE in impresspages plugin trouble

At first, it is need to know I get active the FullTinyMCe and TinyMCEComplete plugins in Impresspages. Well, I have a new plugin where I have a field like this:
$fields[] = array(
'label' => 'Rich Text to Store',
'field' => 'textToStore',
'type' => 'RichText',
'preview' => '\Plugin\MyPlugin\Helper::previewText'
);
How do I do to force the type RichText using the versatility of the FullTinyMCE instead of internal configuration? I need other skills in this field like html edit and save for instance.
Thanks for the aid!
These plugins alter the config just for themselves. If you want to update TinyMCE globally, change the implementation of ipTinyMceConfig() function. This is the default function that provides the configuration of TinyMCE. Replace it with your own function (this is all about JavaScript) that returns your custom configuration. That will take affect everywhere on ImpressPages. More about that:
https://www.impresspages.org/docs/tinymce

Additional page property fields in TYPO3 CMS 6.2

What would be the recommended method to add custom page property fields in TYPO3 6.2?
In 4.5 I used TemplaVoila which had its own page module and made it easy to add data records on a page level.
There are several approaches:
The "vanilla" approach:
Create an extension (and with it the file ext_emconf.php) and then create a file ext_tables.sql in the extension root. In it you can put SQL-definitions for the new fields, by defining a CREATE TABLE statement for the pages table:
CREATE TABLE pages(
myNewField int(11) DEFAULT '',
);
This SQL-definition will be merged with existing definitions for the table page.
Then you need to configure the new field in the Table Configuration Array (TCA). You can usually find good examples in existing extensions, for example in realurl. There are two places where you can put these definitions, either in the file ext_tables.php (uncached), or into a php file in the folder Configuration/Tca/Overrides (cached).
This approach sounds like more work than it actually is.
Just use TemplaVoila. It is available for TYPO3 6.2, but its future is uncertain, AFAIK.
Use the fluidtypo3-Ecosystem of extensions, and especially the extension fluidpages. It does what you want, in a similar way to TemplaVoila, but with modern (= fluid-based) technologies.
if you need your own custom content elements, i recommend the extension "DCE" (Dynamic Content Elements).
DCE is really easy to customise and you can create Content elements in some minutes.
Also you can do it like Jost said. Do it with an own extension and put the TCA definition in your extTables.php
As example:
/www/htdocs/website/typo3conf/ext/custom_extension/ext_tables.php
$tmp_itm_extended_columns_pages = array(
'link_class' => array(
'exclude' => 0,
'label' => 'LLL:EXT:itm_extended/Resources/Private/Language/locallang_db.xlf:label.linkClass',
'config' => array(
'type' => 'select',
'items' => array(
array('Nichts', ''),
array('Zahnrad', 'icon-afford', 'EXT:custom_extension/Resources/Public/img/icons/icon_preferences_small.png'),
array('Fabrik', 'icon-factory', 'EXT:custom_extension/Resources/Public/img/icons/icon_factory_small.png'),
array('Computer', 'icon-software', 'EXT:custom_extension/Resources/Public/img/icons/icon_software_small.png'),
array('Person', 'icon-jobs', 'EXT:custom_extension/Resources/Public/img/icons/icon_person_small.png'),
array('Welt', 'icon-world', 'EXT:custom_extension/Resources/Public/img/icons/icon_world_small.png'),
array('Rohre', 'icon-pipe', 'EXT:custom_extension/Resources/Public/img/icons/icon_pipe_small.png'),
),
),
),
);
Then you have to add your new field to the ext_tables.sql
#
# Table structure for table 'pages'
#
CREATE TABLE pages (
link_class text
);

Typo3 override backend classes

It's been a few weeks I work on Typo3 6.2 and I want to know how to override Typo3 Core classes.
In my case, I have to edit the way select html objects are displayed (I want to add optgroup but Typo doesn't allow us to do it). So I edited the file "FormEngine.php" (typo3/sysext/backend/Classes/Form) and now it works.
But this isn't healthy for future upgrade.
Is there a way to override core classes like any other CMS would allow us to do ?
And I haven't been able to find something on the Internet and I think it could be useful.
Thank you :)
Zisiztypo
Instead of modifying source code of CMS you can just declare a field with a user type and then point your custom userFunc
From the ref:
'tx_examples_special' => array (
'exclude' => 0,
'label' => 'LLL:EXT:examples/Resources/Private/Language/locallang_db.xlf:fe_users.tx_examples_special',
'config' => array (
'type' => 'user',
'size' => '30',
'userFunc' => 'Documentation\\Examples\\Userfuncs\\Tca->specialField',
'parameters' => array(
'color' => 'blue'
)
)
),
TIP: Using this approach, you can create ANY type of field you need, it can be i.e. Google Maps selector, set of fields with common dependencies filled by JS, etc, etc.

Extend/Change extensions in TYPO3

I wanted to ask, how to change files in a TYPO3-Extension, that they wont be overwritten after an update of the specific extensions.
I know that there are 'hooks', but they only give me some functions, not the hole controller file of an action.
Are there some best practices or do I only have the option to never update that extension?
Greets
Agash Thamo.
This depends on various factors.
Extbase Extensions
If the Extension is based on Extbase, you could write your own Extension with your custom Controller and use the domain model of the original extension. Since you didn't really specify which extension you want to modify, this is only a general approach.
Hooks
Are not necessarily provided by extensions. You can always ask the extension author to provide a new hook.
XCLASS
With XCLASS, you can overwrite a class from your own extension. You can find more information about this here. If you update the original extension, you probably need to adjust your XCLASS code.
Directly modify an existing Extension
You should avoid doing this. But if it is your only option, you can modify the file "ext_emconf.php" of the extension and set "state" to "excludeFromUpdates":
$EM_CONF[$_EXTKEY] = array(
'title' => 'Extension Title',
'description' => '',
'category' => 'plugin',
'state' => 'excludeFromUpdates',
...
);
This excludes an extension from updates.