[TYPO3] Mark external links

Sebastian Fuchs sebastian at hexerei.net
Tue Jul 11 13:28:32 CEST 2006


Hi,
there is a solution with the userFunc (i think i saw it the first time 
in the great gov_accessibility extenions by Jan Wischnat but there where 
also some examples in the list, look for typolink & userFunc):

TS-Code:
Constant:
intLinkImage = path/to/your/internalLinkImage
extLinkImage = path/to/your/externalLinkImage
mailLinkImage = path/to/your/mailLinkImage

Setup:
####################################################
### Showing icons for internal and external links (also in headers)
####################################################

page.includeLibs.user_typolink = 
EXT:gov_accesibilty/scripts/class.user_typolink.php

tt_content.image.20.1.imageLinkWrap.typolink.userFunc = user_typolink->main
tt_content.textpic.20.1.imageLinkWrap.typolink.userFunc = 
user_typolink->main

tt_content.text.20.parseFunc {
   tags.link.typolink.userFunc = user_typolink->main

   tags.link.typolink.userFunc {
	  intLinkImage = {$intLinkImage}
	  extLinkImage = {$extLinkImage}
	  mailLinkImage = {$mailLinkImage}
   }

   tags.typolist.default.parseFunc.tags.link.typolink.userFunc < 
.tags.link.typolink.userFunc

}
lib.stdheader.stdWrap.typolink.userFunc < 
tt_content.text.20.parseFunc.tags.link.typolink.userFunc

# Link in Typolist
RTE.default.proc.allowTagsInTypolists = a,br,b,i,u,img

#Links in tt_news
plugin.tt_news.general_stdWrap.parseFunc < tt_content.text.20.parseFunc


PHP-Code class.user_typolink.php:

<?php
class user_typolink {
	var $cObj;    // reference to the calling object.
	function main($content,$conf)    {
		global $TSFE;
		$image = 
$GLOBALS['TSFE']->tmpl->setup['tt_content.']['text.']['20.']['parseFunc.']['tags.']['link.']['typolink.']['userFunc.'];
		if ($content["TYPE"] == "url"){
			 $linkTitle = "Externer Link zur Seite ".$content["url"];
	         $linkImg = '<img class="linkIntImg" 
src="'.$image["extLinkImage"].'" alt="Symbol: Externer Link">';
		}

		elseif ($content["TYPE"] == "mailto"){
			 $linkTitle = "E-Mail Link: Ein Klick öffnet Ihr E-Mail Programm, 
erstellt eine neue Nachricht und fügt die Empfängeradresse ein ...";
	         $linkImg = '<img class="linkMailImg" 
src="'.$image["mailLinkImage"].'" alt="Symbol: E-Mail Link">';
          }

         else {
		 	$linkTitle = "Interner Link zur Seite 
http://www.schwangau.de/".$content["url"];
          	$linkImg = '<img class="linkIntImg" 
src="'.$image["intLinkImage"].'" alt="Symbol: Interner Link">';
		     }
       	return $linkImg.'<A 
HREF="'.$content["url"].'"'.$content["targetParams"].$content["aTagParams"].'title="'.$linkTitle.'">';
     }
}

if (defined("TYPO3_MODE") && 
$TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/gov_accessibility/scripts/class.user_typolink.php"]) 
{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/gov_accessibility/scripts/class.user_typolink.php"]);
}

?>



I have not figured out how to archive this php-script with multilinugual 
  link text. if some has a solution please post it.

hope it helps,
sebastian



Christopher wrote:
> Hi again,
> 
> On 7/10/06, Robert Markula <robert.markula at gmx.net> wrote:
> 
>> Hi Christopher,
>> Your javascript solution is very elegant, but unfortunately exactly this
>> is the bait: we must not use any javascript except for
>> spamProtectEmailAddresses.
>> I've searched quite a bit to solve this issue (it *can* be solved, it's
>> absolutely possible to automate this), but did not find an answer so
>> far. Perhaps I'm looking at this from a wrong angle?
>>
>> <puzzled>Ro</puzzled>
> 
> 
> Ah too bad. Javascript is a nice way of dealing with stuff like links.
> Just taking a quick look at lib.parseFunc.tags.link.typolink, it seems
> to me that you might be able to do what you need with a .postUserFunc.
> You could take the finished typolink, do a regex check for domain.tld
> where domain != the current domain and insert your class attribute.
> Much less elegant, but I think it should work in principle.
> Unfortunately I have no solution at the ready as with the js bit ;-)
> 
> 
> -Christopher



More information about the TYPO3-english mailing list