[TYPO3-dev] Link Problems with pi_base/ solved

Daniel Brüßler info at -remove-patchworking.de
Sat Feb 3 20:53:19 CET 2007


Hello Elmar and Steffen,

It works properly with the section-attribute!! For extensions what use
pi_base in the moment it would be best to add the anchor - feature to
pi_base IMHO. I chose "pi_linkTP", because this has also the cache-feature.

In the moment I've put the following function into dr_wiki. The call in
function "doTocLine" is pretty simple and now the TOC of dr_wiki works
properly with RealURL:
$link = $this->pi_linkTPWithAnchor($tocline, $anchor) . '<br />';

Who cares for pi_base? Would be good to have this variant inside!

kind regards
Daniel Brüßler

---------------------------
/**
 * pi_linkTPWithAnchor
 *
 * this is copy of pi_linkTP but allows also to add an anchor
 * what can be rendered by RealURL
 * so this can be used e.g. to create a TOC for dr_wiki
 *
 * glossary for TYPOLINK:
 * section: a link-anchor what is defined by the "#"-sign
 *
 * @param	[string]		$str: the label / title
 * @param	[string]		$anchor: the anchor / section of page
 * @param	[array]			$urlParameters: Array with URL parameters as
key/value pairs. They will be "imploded" and added to the list of
parameters defined in the plugins TypoScript property "parent.addParams"
plus $this->pi_moreParams.
 * @param	[int]			$cache: If $cache is set (0/1), the page is asked to
be cached by a &cHash value (unless the current plugin using this class
is a USER_INT). Otherwise the no_cache-parameter will be a part of the link.
 * @param	[int]			$altPageId: Alternative page ID for the link. (By
default this function links to the SAME page!)
 * @return	[string]		HTML-code of the link
 */
function
pi_linkTPWithAnchor($str,$anchor,$urlParameters=array(),$cache=0,$altPageId=0)
{
	$conf=array();
	$conf['useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
	$conf['no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
	$conf['section'] = $anchor;
	$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;

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

} // end of pi_linkTPWithAnchor

---------------------------




More information about the TYPO3-dev mailing list