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

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark