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

Emiliano Kamppeter gruenbaer at gmx.net
Mon Jul 18 22:30:35 CEST 2011


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"]);
}


More information about the TYPO3-english mailing list