Typo3

Customize Templavoila new content element wizard

templavoila.wizards.newContentElement {
# Activate tabs for new content element wizard in TV
renderMode = tabs

wizardItems.common.elements.tx_custom_bigimage {
icon = Images/Bigimage.png
title = BG Image
description = BG Image
tt_content_defValues {
CType = tx_custom_bigimage
}
}
wizardItems.common.show := addToList(tx_custom_bigimage)
}

Where tx_custom_bigimage is custom content type. we need to add this code in pagetsconfig of root page.

Please refer to screenshot for more info.New content Element Wizard

Debug Objects in Typo3 Extbase and Typo3 Neos

Simple way to debug an object or variable in Typo3 Latest version is:
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($object);

Note: This works only with version 4.7 and higher

Similarly in case of Neos in order to print an object we use below code:
\TYPO3\FLOW3\var_dump($object);

Clear Cache on Typo3 Neos

Currently there is no option in backend to clear cache.Instead we need to clear cache via command prompt.
There are two types of caches in Typo3 Neos.

1.Production Cache

To clear production cache use below command.

FLOW_CONTEXT=Production ./flow flow:cache:flush --force

2 Development Cache

To clear development cache use below command.

./flow flow:cache:flush --force

We have also command to clear particular cache
Example :

./flow flow:cache:flushone TYPO3_TypoScript_Content

Prevent Search Engines from flooding the Encode Cache – using an XCLASS

The RealURL encode cache could get flooded with the URLs that are used by search engines like Google, Solr etc… If we know the exact parameter they use, we can prevent the flooding using this simple function given below

1.) Add this code to the file “Realurl.php” in the “Sconfig\Xclass” folder. Here “Sconfig” – is the name of our extension. “Xclass – folder may need to be created if not present”

CODE START
########################

<?php

namespace Scwebs\Sconfig\Xclass;

class Realurl extends \tx_realurl {
public function encodeSpURL(&$params) {
parent::encodeSpURL($params);
}

protected function encodeSpURL_encodeCache($urlData, $internalExtras, $setEncodedURL = ”) {
// \TYPO3\CMS\Core\Utility\GeneralUtility::devLog(‘Inside the hook now!’, ‘realurl’, 1, array($urlData));
if( isset($_GET[‘gclid’]) ){
$this->devLog(‘gclid detected. Not doing anything!’);
return ”;
}
parent::encodeSpURL_encodeCache($urlData, $internalExtras, $setEncodedURL);
}
}

########################
CODE END

2. Our Xclass needs to be registered, this can be done in the “Sconfig/ext_localconf.php” using the code below:

$GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘Objects’][‘tx_realurl’] = array(
‘className’ => Scwebs\\Sconfig\\Xclass\\Realurl’
);

Xclass to force the use of Additional Params in all content links

Suppose you want to add one extra parameter to typolink all over the website
Here is the steps to follow :
Step1:
Include below lines in ext_localconf.php of our extension
$GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘Objects’][‘TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer’] = array(
‘className’ => ‘VenderName\\ExtName\\Xclass\\ContentObjectRenderer’
);
// Also Xclass the old class name for compatibility issues (old extensions may create an instance of “tslib_cObj”)
$GLOBALS[‘TYPO3_CONF_VARS’][‘SYS’][‘Objects’][‘tslib_cObj’] = array(
‘className’ => ‘VenderName\\ExtName\\Xclass\\ContentObjectRenderer’
);

Step2:
Create File with name ContentObjectRenderer.php in Xclass Folder
<?
namespace Vendername\Extensionname\Xclass;

class ContentObjectRenderer extends \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer {

/**
* Adds customerview = 1 in url params
*/
function typoLink($linktxt, $conf) {
if($_GET[‘customerview’] == 1){
$conf[‘additionalParams’] = $conf[‘additionalParams’].’&customerview=1′;
}
$typolink = parent::typoLink($linktxt, $conf);
return $typolink;
}
}
?>

Step3:
Clear the cache and check whether xclass is included or not.
Finally reload the frontend page where all typolinks are added with custom parameter customerview