How to set class to image of tt_content element in typo3


Many time we need to add class to image of tt_content element.

Following script will help you for add class to image element or you can set your own style to image.

tt_content.image.20.1.params.cObject = CASE
tt_content.image.20.1.params.cObject {
  key.field = layout
  default = TEXT
  default.value = class="YOUR-CLASS-NAME"
}

OR 

tt_content.image.20.1.params.cObject = CASE
tt_content.image.20.1.params.cObject {
  key.field = layout
  default = TEXT
  default.value = style="display:block;"
}

Above script will help for set default class to image.

If we want to set some style to second image and third image then following script will help you more.

tt_content.image.20.1.params.cObject = CASE
tt_content.image.20.1.params.cObject {
  key.field = layout
  default = TEXT
  default.value = class="class1"
  1 = TEXT
  1.value = class="class2"
  2 = TEXT
  2.value = class="img-responsive"
}

It will also help you when we want to add class related with responsive layout.

I hope it will work for you and make your day ๐Ÿ˜‰

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

How to replace class of typo3 content element.


In frontend many time we need to change class of element and some time we need to replace old class name with new class name

following script will help you for search any element from content and replacing with new element.

Here we have replace class of tt_content element [ table content element of typo3] with new class [ bootstrap class ]


tt_content.table.20.stdWrap.replacement {
  10 {
    search = class="contenttable 
    replace = data-role="table" class="table table-hover
  }
}

This is will you for bootstrap layout of table.

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to image store in tt_content or sys_file_reference table + TYPO3.


 
If you want to use images field in custom plugin then you have to use following code.

This image will take it from sys_file table. this will be store in tt_content field.

It’s create relations directly to the “sys_file” table by not using MM information.

$tempColumns = Array (
    "images" => Array (
        "exclude" => 0,
        "label" => "Images",
        'config' => array(
            'type' => 'group',
            'internal_type' => 'db',
            'allowed' => 'sys_file',

            'prepend_tname' => TRUE,
            'appearance' => array(
                'elementBrowserAllowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
                'elementBrowserType' => 'file'
            ),

            'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
            'show_thumbs' => '1',
            'size' => '5',
            'maxitems' => '200',
            'minitems' => '0',
            'autoSizeMax' => 40,
        ),
    ),
);

If you want to store it in sys_file_reference table then you have to use following two line in configuration.

It’s create relations using MM information [ sys_file_reference ].

'MM' => 'sys_file_reference',
'MM_match_fields' => array(
    'fieldname' => 'image_fal_group'
),

Since “db” references can be stored for multiple tables the rule is that uid numbers without a table name prefixed are implicitly from the first table in the allowed table list! Thus the list “32,141,72,10” is implicitly understood as “sys_file_32,sys_file_141,sys_file_72,sys_file_10”. That would be equally good for storage,

If you want to add image as tt_content field in your custom plugin then please Click Here

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to image upload in extension of typo3 6.2 version + Drag n drop image functionality in extension of typo3 6.2


 
Its very useful functionality for upload all images from system directory [sys_file]

Drag n drop image functionality also available in flexform of typo3 6.2

You can have to add following configuration in your image field.

Following code need to modify in your tca.php file.


$tempColumns = Array (

   "images"  => Array (
	
      "exclude"  => 0,
      "label"  => "Add your Media",
		
      "config"  => Array (
         "type"  => "inline",
         "internal_type"  => "file",
         "size"  => 10,
         "minitems"  => 1,
         "maxitems"  => 100,
			
         "appearance"  => Array(
            "headerThumbnail"  => Array(
               "field"  =>"uid_local",
                  "height"  =>"45c",
                  "width"  => "45"
               ),
               "enabledControls"  => Array(
                  "delete" => 1,
                  "dragdrop"  => 1,
                  "hide"  => 1,
                  "info"  => 1,
                  "localize"  => 1
               ),
               "useSortable"  => 1
         ),
			
         "behaviour"  => Array(
            "localizationMode"  => "select",
            "localizeChildrenAtParentLocalization"  => 1
         ),
			
         "foreign_field"  => "uid_foreign",
         "foreign_label"  => "uid_local",

         "foreign_match_fields"  => Array(
            "fieldname"  => "fal_filelist"
         ),
			
         "foreign_selector"  => "uid_local",
			
         "foreign_selector_fieldTcaOverride"  => Array(
            "config"  => Array(
               "appearance"  => Array(
                  "elementBrowserAllowed"  => "gif,jpg,jpeg,bmp",
                  "elementBrowserType"  => "file"
               )
            )
         ),
			
         "foreign_sortby"  => "sorting_foreign",
         "foreign_table"  => "sys_file_reference",
         "foreign_table_field"  => "tablenames",

         "show_thumbs" => 1,

      )
   ),
);

it will look like below image.

Flexform + image + typo3 6.2

Flexform + image + typo3 6.2

OR if you want to add image as tt_content field in your custom plugin then please Click Here

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to use tt_content fields in custom plugin of TYPO3.


 
How to add new field in custom plugin option

Its very important and useful for add tt_content field in custom plugin option or in normal content element area.

If you want to set second title field in your tt_content record then you have to set following script in your ext_table.php

$tempColumns = array(
    'subtitle' => array(
        'exclude' => 0,
        'label' => 'title2',
        'config' => array(
            'type' => 'input'
        )
    )
);

Then you have to load tt_content TCA file

This is for EXTBASE Extension
\TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tt_content');

OR

This is for PI Base Extension
t3lib_div::loadTCA("tx_dam_cat");

If you want to display this field in ALL CONTENT ELEMENT then use following script.

This is for EXTBASE Extension
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $tempColumns);

OR

This is for PI Base Extension
t3lib_extMgm::addTCAcolumns("tx_dam_cat",$tempColumns,1);

Third parameter is deprecated in latest version of TYPO3 6.X.X

If you want to display this field in PARTICULAR EXTENSION then use following script.

This is for EXTBASE Extension
$TCA["tt_content"]["types"]["list"]["subtypes_excludelist"]["abc_xyz"]="layout,select_key,pages";
$TCA["tt_content"]["types"]["list"]["subtypes_addlist"]["abc_xyz"]="subtitle;;;;1-1-1";

OR

This is for PI Base Extension
$TCA["tt_content"]["types"]["list"]["subtypes_excludelist"][$_EXTKEY."_pi1"]="layout,select_key,pages";
$TCA["tt_content"]["types"]["list"]["subtypes_addlist"][$_EXTKEY."_pi1"]="subtitle;;;;1-1-1";

Note :
If your extension key is “Abc” and your plugin key is “Xyz”, then the index is “abc_xyz”, all in small.

I hope it will work for you and make your day ๐Ÿ˜‰

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to get current tt_content uid in pi base and extbase extension


 
If you are developing an extension that time you need to get current tt_contect uid then you have to use following script.

Following script will be use PI base extension.

$uid = $this->cObj->data['uid'];

if ($this->cObj->data['_LOCALIZED_UID']) {
    $uid = $this->cObj->data['_LOCALIZED_UID'];
}

Following script will be use in EXT BASE extension.

$this->contentObj = $this->configurationManager->getContentObject();
$uid = $this->contentObj->data['uid'];

I hope it will work for you. ๐Ÿ™‚

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How do I remove p tags in typo3 RTE text content elements


 
Many of user want to remove extra p tag which are generate automatically by TYPO3.

Following script will definitely helping you.

tt_content.stdWrap.dataWrap >
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines >

Remove Class “bodytext” in p tag : <p class=”bodytext”>

lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.addAttributes.P.class =

OR 

lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines.addAttributes.P.class >

Fnally you getting rid of p tag ๐Ÿ˜‰

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya