[TYPO3-ttnews] linking single news record from own extension (cHash)

Martin Clewing mpc at clewing.de
Tue Jul 18 15:09:51 CEST 2006


Hi,

guess I have it:

if ($this->internal['currentRow']['rel_news']!=''){
// liste aufsplitten
foreach(explode(",",$this->internal['currentRow']['rel_news']) as $k => $i){
                  $res = 
$GLOBALS["TYPO3_DB"]->exec_SELECTquery("uid,title,datetime,short,tx_mpcnewsext_place","tt_news","1 
AND tt_news.uid = '".$i."' AND tt_news.deleted!='1' AND 
tt_news.hidden!='1'");
                  while($row = mysql_fetch_assoc($res)) {
        $urlConfig=array(
                'parameter' => '40',
                'cache' => 'TRUE',
                'additionalParams' => 
'&tx_ttnews[tt_news]='.$row['uid'].'&tx_ttnews[backPid]='.$GLOBALS['TSFE']->id
                );

        $news.= $this->cObj->typolink('<b>'.$row['title'].'</b>', 
$urlConfig).' '.strftime('%A, %e. %B 
%Y',$row["datetime"]).'('.$row["tx_mpcnewsext_place"].')<br />';

                  }
}
}
                  return "<b>verwandte News:</b><br />".$news;


Any reasons this shouldn't work? Looks ok so far in frontend. Of course 
I still have to add some additional SQL to avoid archived News and 
include certain PIDs, but so far...

Thanks for helping, Ernesto!

Best regards,
Martin


Martin Clewing schrieb:
> Ernesto Baschny [cron IT] schrieb:
> 
>> Martin Clewing schrieb am 11.07.2006 10:14:
>>
>>
>>> I stumbled over a little (hopefully) problem: how can I link a single
>>> news from within an extension?
>>>
>>> I managed to link a news-entry when I disable cashing, but (of course) I
>>> need caching for indexed search, so this is no option.
>>>
>>> In other words: how do I create the cHash? Is there any way to do that
>>> at all? I looked into the tt_news extension, hoping to find the clue,
>>> but it's slightly beyond my horizon... which fields go into PiVars?
>>>
>>> The solution I found in this list (posted a year ago) was this:
>>> including a link-field in my extension where the news-articles url is
>>> inserted. That is not as comfortable as I would like it to be AND
>>> excludes any hide/timestamp/archive-functionality, which is really a
>>> great loss.
>>>
>>> Any ideas/help/solutions maybe?
>>
>>
>>
>> You should use the "typolink" function to create the link. Just pass it
>> the correct $conf:
>> - parameter: the page-id where to display the single news
>> - additionalParams: the parameters just like tt_news does it
>> - and: useCacheHash=TRUE so it will generate the corresponding cHash.
>>
>> Note that you need to use the exact same parameters as tt_news, else the
>> cHash will differ.
>>
>> Documentation for the typolink function:
>>
>> http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/5/8/ 
>>
>>
>> Call it through a valid cObj.
> 
> 
> Thanks, Ernesto,
> 
> that's the theory behind as far as I understood. The only problem now 
> is: how exactly do I do that? Like I wrote: it's slightly beyond my 
> horizon. Are there any examples somewhere? tt_news itself is slightly 
> too complicated to unveal it's secrets to me :-(
> 
> this is as fas as I got, displaying the headline, date, etc,...:
> 
> ------------------------
> if ($this->internal['currentRow']['rel_news']!=''){
> // split list od related news
> foreach(explode(",",$this->internal['currentRow']['rel_news']) as $k => 
> $i){
> $res = 
> $GLOBALS["TYPO3_DB"]->exec_SELECTquery("title,datetime,short,tx_mpcnewsext_place","tt_news","1 
> AND tt_news.uid = '".$i."' AND tt_news.deleted!='1' AND 
> tt_news.hidden!='1'");
> while($row = mysql_fetch_assoc($res)) {
> $news.="<b>".$row["title"]."</b><br />".strftime('%A, %e. %B 
> %Y',$row["datetime"]).", ".$row["tx_mpcnewsext_place"]."<br 
> />".$row["short"]."<br /><br />";
>                  }
> }
> }
> return "<b>related news:</b><br />".$news;
> 
> -----------------------
> 
> tx_mpcnewsext_place is an additional field inserted by my extension.
> 
> Any help would be apprecciated.
> Thanks,
> Martin



More information about the TYPO3-project-tt-news mailing list