[Typo3-dev] Hint : Alternative typoLink label with cHash+SimulateStatic

Jean-Baptiste Rio triphot69 at hotmail.com
Mon Oct 10 14:05:26 CEST 2005


Hi List,

Just M2P to enhance Typo3 functions. I use 3.7.0 so maybe my hint is not 
useful for 3.8.0.

There are many question on the uselist about external data and cache 
possibilities. For my part, i need these functions to put in cache some 
IPB forum topics which are displayed as news on my sites. So i wrote an 
plugin which reads a whole IPB topic (including answer posts) and 
displays it on a page. The problem is : I can't declare as many pages as 
news topics to put into cache the topics contents. That's why i use a 
cHash on my page and it works great (Thx kasper and the core dev team).
A typical link for visitors to view my topic is :
http://www.mysite.com/index.php?id=1200&topic=12589&cHash=08qfcg89

id = typo3 page where i put the IPB plugin
topic = IPB topic id

And i have a different cHash for each topic. Everything ok.

Now i want to be indexed by google. So i decided to use SimulateStatic 
with md5.
No problem at all, now the link are :
http://www.mysite.com/newsipb.1200.0.BgHj00a582.html

The last point is the reason of this thread. My staff want that the 
topic title appears in the link. Something like :
http://www.mysite.com/The_Title_Of_My_IPB_topic.1200.0.BgHj00a582.html

So i dive into Typo3 to find a solution. I use pi_LinkTP in my IPB 
extension. Here are the steps to do it :

1 - Modify pi_linkTP function in class.tslib_pibase.php (line 307 and 
next) - Add a new parameter altTitle

function pi_linkTP($str,$urlParameters=array(),$cache=0,$altPageId=0, 
$altTitle='')	{
	$conf=array();
	$conf['useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
	$conf['no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
	$conf['parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ? 
$this->pi_tmpPageId : $GLOBALS['TSFE']->id);
	$conf['additionalParams'] = 
$this->conf['parent.']['addParams'].t3lib_div::implodeArrayForUrl('',$urlParameters,'',1).$this->pi_moreParams;
+	$conf['altTitle'] = $altTitle;

	return $this->cObj->typoLink($str, $conf);
}

2 - Modify function typoLink in class.tslib_content.php (line 4999 and next)

+ $overrideArray='';
+ if ($conf['altTitle'] != '') $overrideArray = 
array('title'=>$conf['altTitle']);
+ $LD = 
$GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'',$overrideArray,$addQueryParams,$theTypeP);
- $LD = 
$GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP);

3 - Put into comment the line 1282 in class.t3lib_tstemplate.php 
(function linkData)

if (is_array($overrideArray))	{
	foreach($overrideArray as $theKey => $theNewVal)	{
//$addParams.= '&real_'.$theKey.'='.rawurlencode($page[$theKey]);
	$page[$theKey] = $theNewVal;
	}

I've just used the standard $overrideArray parameter to do it. I had to 
put into comment the "$addParams .=..." line because it generates an 
error with the cHash : the cHash is calculated before the &real_ 
parameter is added to the link. So it refused to put into cache the page 
because of the difference between the provided cHash and the calculated 
cHash.

Hope it could be added to the core. But, maybe, it is not interesting... 
so i've preferred open a thread here before log in as a asked feature in 
the bugtracker.

Regards,

Jean-Baptiste




More information about the TYPO3-dev mailing list