Author: Karsten Hachmeister
In this short tutorial I want to show, how you can make Typolinks in your extension that support the 'Simulate Static Documents' Feature and create output that get be cached by Typo3, so that the indexed search can be used with it. These information are collected from other extensions, specifically from the tt_board extension.
First make sure your file 'ext_typoscript_setup.txt' contains a property which tells your extension if it should use the caching:
plugin.tx_myextension_pi1 {
allowCaching = 1
}
If you set this later to '0' the pages will not be cached.
In the main() function prepare the Typolink and configure the caching:
class tx_myextension_pi1 extends tslib_pibase {
...
var $allowCaching = "";
function main($content,$conf) {
$this->conf=$conf;
...
// Preconfigure the typolink
$this->local_cObj = t3lib_div::makeInstance("tslib_cObj");
$this->local_cObj->setCurrentVal($GLOBALS["TSFE"]->id);
$this->typolink_conf = $this->conf["typolink."];
$this->typolink_conf["parameter."]["current"] = 1;
$this->typolink_conf["additionalParams"] =
$this->cObj->stdWrap($this->typolink_conf["additionalParams"],
$this->typolink_conf["additionalParams."]);
unset($this->typolink_conf["additionalParams."]);
// Configure caching
$this->allowCaching = $this->conf["allowCaching"]?1:0;
if (!$this->allowCaching) {
$GLOBALS["TSFE"]->set_no_cache();
}
...
}
}
To create now a link in your extension use the following code fragment:
$temp_conf = $this->typolink_conf;
$temp_conf["additionalParams"] .= "&tx_myextension_pi1[key]=value";
$temp_conf["useCacheHash"] = $this->allowCaching;
$temp_conf["no_cache"] = !$this->allowCaching;
$the_link = $this->local_cObj->typolink("Linktext", $temp_conf);
After that you can add '$the_link' to your output. The '$temp_conf' array you can extend with all properties from the typolink Object.
If you have further questions to this tutorial, please ask them in the forum.