Home Contact Us Sitemap News Forums Japanese Lessons Fan Art Fan Fiction Download
Main Menu
  Community
News
Forums (ext.)
Log In
Register Account
Resources
Fan Art
Fan Fiction
Stories
Japanese Lessons
Cutest Anime Girl
Downloads
Links
Sitemap
Documentation
All Anime World FAQ
Site Search
Affiliates
Link Us!
Impressum
 
Catnip Box
  ###DROPBOX###  
Toolbox
   Print View
 Text Only
 Bookmark us!
Call a dog and they come, call
a cat and they take a message
and get back to you later.
Oldwrench, chat 13th Apr

 
Affiliates
 




Firefox 3
- More Cool Sites -
 

  Yo. I'm Link-A-Licous!

A few years ago when we were trying to write our first plugins for TYPO3 (3.5) linking was done the hard way. The stakes were high, men were real men, women were real women and small furry creatures from Alpha Centauri were real small furry creatures from Alpha Centauri. (Sorry couldn't resist to add the needed Douglas Adams quote)

Back in 2002 some code like $content .= "link"; was enough to keep the developer happy. Then TYPO3 evolved. Rarely known features were utilized, TypoScript was enhanced and a certain amount of plugins like realurl added to the TES. Page caching and cHash, page index, multi language sites, and some other systems made linking even more complicated.

 

Today a robust and yet flexible system involves alot more than a casual $content.="<A..."

 

<strong>Intended Audience: Everybody who needs to create very long links with lots of parameters as opposed to the simple "move-to-page-x" links which more comfortable functions have been written for. Hopefully people will finally cease to use hard coded URLs in their extensions.

 

Gladly, TYPO3 has all necessary features built right into the plugin class pi_base. The central function typolink does all the hard work, but it has some limitations. All the other link functions placed into pi_base is calling the typolink function to create their links. Let's have a look at some sample code:


  $lConfig = array("useCacheHash" => 1,
    "no_cache" => 0,
    "parameter" => $GLOBALS["TSFE"]->id,
    "additionalParams" => "&action=displaySingle&knr=".$prow["bdnr"]);
  $mylink = $this->cObj->typoLink("", $lConfig);

An array $lConf is initialized with necessary parameters, then passed to the function typolink. Typolink() will take care of everything. It will analyze the page ID and take into account the various TypoScript configurations, it will eventually pass the data to extensions like realurl and return a ready-for-content link tag featuring the text written into the first parameter. It will also calculate the necessary cHash value which is TYPO3's implemented anti-spam feature.

 

Voila. That's it. Nothing to worry about. You can copy the code above and paste it into your extensions. Now a few simple tricks which might prove useful. For example if you'd like to link the parent page instead of the current one, you exchange the array value "parameter":

$lConf["parameter"] = $GLOBALS["TSFE"]->page["pid"];

You will also most likely have a need for the URL separated from the link, e.g. whilemanually creating custom forms, where a link tag is of little use. TYPO3 will store the last created link into the variable:

 

$myURL = $this->cObj->lastTypoLinkUrl;

 

 


More information

Please refer to these pages for more information about linking, cHash, and usage of $lConf parameters:

 Kasper Skarhoj: The Mysteries of cHash

Explaining the secret of the &cHash GET-Parameter and it's importance to avoid DOS attacks on your website. It also explains when to use the parameters no_cache and useCacheHash.

 Robert Lemke: Using Links in Frontend Plugins

You don't need to pass parameters to your plugins? There are plenty of easy to use functions built into the plugin superclass allowing link creation without building a $lConf array.

 The Typolink() function code

This is the actual code of typolink(), great for reference and to find more parameters to add to $lConfig in future versions of TYPO3.

 


All articles by Olray and Sakura

 Fantasy Name Generator
 UTF-8 howto
 TYPO3 scaling images by code
 TYPO3 Power-Linking
 TYPO3 Rotating Images

 
Privacy Policy | Terms & Conditions