Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Titelproblem, Umlaute ersetzen

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
ven
Smarty Rookie


Joined: 28 Jan 2007
Posts: 6

PostPosted: Sat Mar 03, 2007 9:52 am    Post subject: Titelproblem, Umlaute ersetzen Reply with quote

Hallo,

ich habe folgendes Problem: Die Detail-URL, die angezeigt wird, hat den Titel meiner in meinen Webkatalog eingetragenen Webseiten.
Sprich: "Hans tolle Webseite für alles"

Wäre dann als URL: www.meinewebseite.de/details/Hans_tolle_Webseite_für_alles.html

Problem ist, dass ich die Umlaute das rauskriegen muss. Ich habs wie folgt versucht, aber es klappt einfach nicht:

{$link.TITLE|escape|trim|replace:" ":"_"|replace:"Ä":"Ae"|replace:"Ü":"Ue"|replace:"Ö":"Oe"|replace:"ä":"ae"|replace:"ö":"oe"|replace:"ü":"ue"|replace:"Ä":"Ae"|replace:"Ö":"Oe"|replace:"Ü":"Ue"|replace:"ä":"ae"|replace:"ö":"oe"|replace:"ü":"ue"}

Kann mir da jemand weiterhelfen?
Back to top
View user's profile Send private message
Stoke
Smarty n00b


Joined: 24 Feb 2007
Posts: 4

PostPosted: Sat Mar 03, 2007 10:40 am    Post subject: Reply with quote

Machs einfach in php, wie das mit Smarty funktioniert kann ich dir leider auch nicht sagen...

Hier mal meine Funktion dafür, vielleicht hilft dir das Wink
Schreib sie dir einfach so um wie du sie brauchst!

Code:
   function umlaut($text) {
      $char      = '/ä/';
      $replace   = 'ä';
      $text      = preg_replace($char, $replace, $text);

      $char      = '/Ä/';
      $replace   = 'Ä';
      $text      = preg_replace($char, $replace, $text);
      
      $char      = '/ö/';
      $replace   = 'ö';
      $text      = preg_replace($char, $replace, $text);
      
      $char      = '/Ö/';
      $replace   = 'Ö';
      $text      = preg_replace($char, $replace, $text);
      
      $char      = '/ü/';
      $replace   = 'ü';
      $text      = preg_replace($char, $replace, $text);

      $char      = '/Ü/';
      $replace   = 'Ü';
      $text      = preg_replace($char, $replace, $text);
      
      $char      = '/ß/';
      $replace   = 'ß';
      $text      = preg_replace($char, $replace, $text);
      return $text;
   }


Hoffe dass ich helfen konnte!

Gruß,
Stoke
Back to top
View user's profile Send private message
ven
Smarty Rookie


Joined: 28 Jan 2007
Posts: 6

PostPosted: Sat Mar 03, 2007 11:07 am    Post subject: Reply with quote

Das müsste ich dann wahrscheinlich vor die ausgabe/weitergabe des $Titels an die .tpl Datei setzen richtig? Ich weiß leider nicht wo die verarbeitet/weitergegeben wird.
Back to top
View user's profile Send private message
Stoke
Smarty n00b


Joined: 24 Feb 2007
Posts: 4

PostPosted: Sat Mar 03, 2007 4:58 pm    Post subject: Reply with quote

Nein, das hat mit den Templates nix zu tun.

Das kommt in die php Datei (normalerweise hat man für Funktionen eine functions.php, die man einfach includet wenn sie gebraucht wird; aber das is eigentlich egal).

Danach übergibst die Variable wie gehabt ans Template, nur dass du eben die Funktion aufrufst.
So in etwa:

Code:
$smarty->assign('titel', umlaut($titel));
Back to top
View user's profile Send private message
ven
Smarty Rookie


Joined: 28 Jan 2007
Posts: 6

PostPosted: Sun Mar 04, 2007 4:17 pm    Post subject: Reply with quote

alles klar danke. und wie kann ich die variable an ein bestimmtes template weitergeben? weil das template an die ich die variable weitergeben möchte besitzt eine .php datei.
Back to top
View user's profile Send private message
gnuffmaster
Smarty Elite


Joined: 13 Jul 2006
Posts: 440
Location: Düsseldorf, Germany

PostPosted: Mon Mar 05, 2007 8:14 am    Post subject: Reply with quote

Schau Dir mal die Kapitel zu Modifier in der Doku an z.B.:
http://smarty.php.net/manual/en/plugins.modifiers.php

Eine Variable übergibst Du mit assign:
http://smarty.php.net/manual/en/api.assign.php

@Stoke:
Reichlich umständlich, wo es doch eine schöne Funktion htmlentities() gibt, die das alles schon macht und die man auch als modifier nutzen kann Wink
Back to top
View user's profile Send private message Visit poster's website
Stoke
Smarty n00b


Joined: 24 Feb 2007
Posts: 4

PostPosted: Fri Mar 09, 2007 6:38 pm    Post subject: Reply with quote

Naja, ich wollte ne Funktion die nur die Umlaute ersetzt.
htmlentities() eretzt ja alle Sonderzeichen, somit kann man kein HTML mehr aus der Datenbank ausgeben.
Back to top
View user's profile Send private message
Max-3D
Smarty Regular


Joined: 22 Dec 2005
Posts: 37

PostPosted: Sun Oct 27, 2013 8:04 pm    Post subject: Reply with quote

Bei mir geht der Code oben perfekt !!!
Danke ich brauchte es, suchte es und 1 Minute später ließ es perfekt Smile


Gruß Maxen
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP