Hier ist eine aktualisierte Version der PHP-Function im File 
ts_user_functions.php. Diese Version berücksichtigt den URL-Type (http, 
https, ftp, mailto), der im Backend zusammen mit der URL-Eingabe gewählt 
werden kann:


<?php
class user_functions{

   function user_addLangIdToExternalUrl($content, $conf){
     // get params from calling TS
     $pLangUID = $conf['langUID'];  // config.sys_language_uid

     // if link type is "external url" replace link to redirecting page 
with external url and add language param
     if($this->cObj->data['doktype']==3){
       $urlSchemes = array(0=>'', 1=>'http://', 2=>'ftp://', 
3=>'mailto:', 4=>'https://');
       $content = preg_replace('/(<a[^>]*href=")[^"]*("[^>]*>)/i', 
'$1'.$urlSchemes[$this->cObj->data['urltype']].$this->cObj->data['url']."?L=$pLangUID".'$2',
 
$content);
     }

     return $content;
   }

}
?>


Viele Grüße,
Jörg.


Joerg Wagner schrieb:
> Hallo Stephan,
> 
>  > ich möchte per typoscript einen Paramter an einen externen Link in einem
>  > Text-Content-Element anhängen.
> 
> Ich hatte ein ähnliches Problem mit Menüpunkten, die z.T. auf eine 
> externe Website verweisen sollten und dabei ebenfalls den L-Parameter 
> mit übergeben sollten. Hat mich viel Zeit gekostet - vielleicht hilft 
> Dir meine Lösung weiter.
> 
> 
> TS-Setup:
> 
> config.sys_language_uid = 0
> [globalVar = GP:L=1]
>   config.sys_language_uid = 1
> [global]
> [globalVar = GP:L=2]
>   config.sys_language_uid = 2
> [global]
> ...
> 
> includeLibs.myUserFunctions = fileadmin/templates/php/ts_user_functions.php
> 
> ...
> 
> # TS des Menüs in dem die externen URLs definiert sind:
> lib.mainMenu = HMENU
> lib.mainMenu {
>   1 = GMENU
>   1 {
>     NO {
>       allStdWrap.postUserFunc.langUID < config.sys_language_uid
>       allStdWrap.postUserFunc = user_functions->user_addLangIdToExternalUrl
>       ...
>     }
>   ...
>   }
> }
> 
> 
> 
> Die PHP-Function in der Datei ts_user_functions.php sieht so aus:
> 
> <?php
> class user_functions{
>   function user_addLangIdToExternalUrl($content, $conf){
>     // get params from calling TS
>     $pLangUID = $conf['langUID'];  // config.sys_language_uid
> 
>     // if link type is "external url" replace link to redirecting page 
> with external url and add language param
>     if($this->cObj->data['doktype']==3){
>       $content = preg_replace('/(<a[^>]*href=")[^"]*("[^>]*>)/i', 
> '$1http://'.$this->cObj->data['url']."?L=$pLangUID".'$2', $content);
>     }
> 
>     return $content;
>   }
> }
> ?>
> 
> 
> Sollte so auch für TMENU funktionieren. Nebeneffekt ist, dass das 
> href-Attribut der so modifizierten Links direkt die externe Adresse 
> enthält und nicht die interne Seitenadresse, die dann redirected wird.
> 
> Viel Erfolg,
> Jörg.
> 
> 
> 
> Stephan Bauer schrieb:
>> Hallo,
>>
>> ich möchte per typoscript einen Paramter an einen externen Link in 
>> einem Text-Content-Element anhängen.
>> Z.B. im Textfeld steht der Link
>> <link www.test.de>Hier klicken</link>
>>
>> An diesen Link möchte ich die aktuelle Sprache meiner Seite anhängen 
>> (z.B. ?lang=de)
>>
>> Zusätzlich möchte ich noch eine per user_func
>> generierte Checksumme anhängen (z.B. &check=098f6bcd)
>>
>> Ich habe mich zu tode gesucht und nichts gefunden.
>>
>> Vielen Dank im Voraus.
>>
>> Grüße
>>
>> Stephan
>>
_______________________________________________
TYPO3-german mailing list
TYPO3-german@lists.netfielders.de
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-german

Antwort per Email an