[TYPO3-english] PHP: Get page title of linked page

Sergey Alexandrov serg at alexandrov.us
Wed Jul 20 01:48:17 CEST 2011


Well, take a look on the rsgoogleanalytics. He uses a TYPO3 hook into 
TYPOLink Generation called linkPostProcess(&$params, &$reference)
This hook called every time while processing any link, so it's very easy 
to modify any link on your page(s) "on the fly"

Hope it could help you,

Serg

On 7/18/2011 4:30 PM, Emiliano Kamppeter wrote:
> Hello,
>
> I found the extension dkd_imagemap, which converts Page-IDs in 
> imagemaps to typolinks.
> This is a very handy feature, but I would futher like to also add the 
> ALT attribute to the Link. The interesting function of dkd_imagemap is:
>
> function tlink ($id) {
>     $page = preg_replace('/href=\"(\d+)\"/', '$1', $id);
>     return 'href="'.$this->pi_getPageLink($page[0]).'"';
> }
>
> Now I had the idea to add some code behind the second line returning 
> the page title of the target page, but alas, I have no clue what that 
> code might look like...
>
> Would someone here please be so kind as to tell me the right code?
>
> Thanks so much,
>
> Emiliano
>
> And here the full code of the extension if you need it...
>
> require_once(PATH_tslib."class.tslib_pibase.php");
>
> class tx_dkdimagemap_pi1 extends tslib_pibase {
>     var $prefixId = "tx_dkdimagemap_pi1";        // Same as class name
>     var $scriptRelPath = "pi1/class.tx_dkdimagemap_pi1.php";    // 
> Path to this script relative to the extension dir.
>     var $extKey = "dkd_imagemap";    // The extension key.
>
>     /**
>      * [Put your description here]
>      */
>     function main($content,$conf)    {
>         $html = preg_replace_callback ("/href=\"\d+\"/", array(&$this, 
> 'tlink'), $this->cObj->data['bodytext']);
>         return $html;
>     }
>
>     function tlink ($id) {
>         $page = preg_replace('/href=\"(\d+)\"/', '$1', $id);
>         return 'href="'.$this->pi_getPageLink($page[0]).'"';
>     }
> }
>
>
>
> if (defined("TYPO3_MODE") && 
> $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/dkd_imagemap/pi1/class.tx_dkdimagemap_pi1.php"]) 
> {
>     include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/dkd_imagemap/pi1/class.tx_dkdimagemap_pi1.php"]); 
>
> }
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english


More information about the TYPO3-english mailing list