How to extend news with extra field in typo3


Many time we need to extend news with some text fields or any other table relation.

We can directly in news extension. better we can extend through other extension.

For that first we need to create that fields in news table.

So following SQL you need to extend in your extension [ in ext_tables.sql file ]

CREATE TABLE tx_news_domain_model_news (
    category int(11) unsigned DEFAULT '0',
);

than after you need to add following code in ext_tables.php. this extended category will display before bodytext area.

$extendCategory = array(
    'category' => array (
        'exclude' => 0,
        'l10n_mode' => 'noCopy',
        'label' => 'Sponsors',
        'config' => array(
            'type' => 'select',
            'items' => array (
                array('',0),
            ),
            'renderType' => 'selectSingle',
            'foreign_table' => 'tx_jsfaq_domain_model_category',
            'minitems' => 0,
            'maxitems' => 1,
        ),
    ),
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
    'tx_news_domain_model_news',
    $extendCategory,
    1
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
    'tx_news_domain_model_news',
    'paletteArchive', '--linebreak--,category','after:bodytext'
);

If you have any query then feel free to contact me at Jainish Senjaliya

Advertisements

How to add elements to the Content Element Wizard in typo3


The content element wizard can be fully configured using TSConfig.

The API described here should not be used for the purpose of customizing this wizard.

However for extension authors, it provides a way of registering their plugin with the new content element wizard.

Basically it is about adding a class reference to the $GLOBALS[‘TBE_MODULES_EXT’][‘xMOD_db_new_content_el’][‘addElClasses’] global array.

The keys in this array are class names and the values are the absolute paths to these class. The class must have a proc() method.

Here is some code from the “js_contact_form” extension, to register the “contactform” plugin with the wizard. First of all, the class is declared:

// add wizard icon to the "add new record" in backend
if (TYPO3_MODE == "BE") {
    $TBE_MODULES_EXT["xMOD_db_new_content_el"]["addElClasses"]["JsContactFormWizicon"] =
         \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/Helper/JsContactFormWizicon.php';
}

The EXT:js_contact_form/Classes/Helper/JsContactFormWizicon.php file looks like:

<?php
/**
 * Created by Jainish Senjaliya.
 * User: Jainish
 * Date: 13.06.2015
 * Time: 15:01
 */
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;

/**
 * Class that adds the wizard icon.
 */
class JsContactFormWizicon {

    /**
     * Processing the wizard items array
     *
     * @param array $wizardItems : The wizard items
     * @return Modified array with wizard items
     */
    function proc( $wizardItems ) {

        $wizardItems['plugins_tx_jscontactform_contactform'] = array(
            'icon' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('js_contact_form') . 'Resources/Public/Icons/wizard_icon.png',
            'title' => $GLOBALS['LANG']->sL('LLL:EXT:js_contact_form/Resources/Private/Language/locallang.xlf:plugin-title'),
            'description' => $GLOBALS['LANG']->sL('LLL:EXT:js_contact_form/Resources/Private/Language/locallang.xlf:plugin-description'),
            'params' => '&defVals[tt_content][CType]=list&defVals[tt_content][list_type]=jscontactform_contactform'
        );

        return $wizardItems;
    }
}
?>

The proc() method receives the list of existing items in the wizard and adds a new one to it.

The first three properties (icon, title and description) are quite easy to understand.

The “params” property defines the default values to be added to the new record link so that the right type of content element (and plugin in this case) is already selected.

The entry added in the plugin list of the new content element wizard

The entry added in the plugin list of the new content element wizard

I have taken this example from Contact Form Extension from TYPO3 Repository. you may download and analyze this extension.

I hope this will help you more. Njoy 🙂 🙂

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 display table content in tab of typo3 extension


 
For display table content in tab of custom extension.

First you have to set “‘dividers2tabs’ => true” in exe_table.php file.

   'dividers2tabs' => true,

Dividers 2 tabs

Dividers 2 tabs


then after you have to modify tca.php file.

below code is original code of Tca file

'types' => array (
	'0' => array('showitem' => 'hidden;;1;;1-1-1, title;;;;2-2-2, images;;;;3-3-3, logo, small_image, address, place, types ')	
),

For set tab you have to add “–div–;Tab1,” before field name.

“Tab1” is stand for title of the tab. Below code is modified code

'types' => array (
	'0' => array('showitem' => '--div--;Tab1,hidden;;1;;1-1-1, title;;;;2-2-2, --div--;Tab2,images;;;;3-3-3, --div--;Tab3,logo, small_image,--div--;Tab4, address, place, --div--;Tab5,types ')
),
Tab in TCA

Tab in TCA

It will look like below image

TCA, Extension, table

TCA, Extension, table

I hope it will help you.. Good luck 🙂

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