Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Umlaute in Variablenamen

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
lord_icon
Smarty n00b


Joined: 31 Jan 2017
Posts: 3

PostPosted: Tue Jan 31, 2017 11:00 am    Post subject: Umlaute in Variablenamen Reply with quote

Hi,

ich nutze JTL wo smarty für die Template zum Einsatz kommt.
Ein Template will ich nun erweitern und bin auf ein Problem bzgl. Sonderzeichen respektive Umlaute gestoßen.

Ausgeben mit einer schleife geht
Code:

 {foreach from=$Artikel->FunktionsAttribute key=key item=item}
      "{$key}" => "{$item}"
{/foreach}

"größenschema_s" => "27.7"
"farbschema_s" => "Blau"
"farbe_s" => "Blau"
"produktname_s" => "CLAS20-BLMPU"
"schuhgröße_s" => "8"



Möchte ich es direkt abfragen, bekomme ich entweder eine weiße Seite oder halt garkein Output.
Folgendes hab ich schon versucht:



Code:

{$Artikel->FunktionsAttribute.größenschema_s}
{$Artikel->FunktionsAttribute.'größenschema_s'}
{$Artikel->FunktionsAttribute['größenschema_s']}
{$Artikel->FunktionsAttribute["größenschema_s"]}
{$Artikel->FunktionsAttribute.["größenschema_s"]}

{assign var=foo value=$Artikel->FunktionsAttribute["größenschema_s"]}
{$foo}


Habe ich noch andere Möglichkeiten ?
Danke
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1055

PostPosted: Tue Jan 31, 2017 1:03 pm    Post subject: Reply with quote

Using questionable characters as list indices is always a risk.
Back to top
View user's profile Send private message
lord_icon
Smarty n00b


Joined: 31 Jan 2017
Posts: 3

PostPosted: Tue Jan 31, 2017 1:13 pm    Post subject: Reply with quote

I get so predefined.

Other idea.

I go through the values and rebuild them
Code:

{foreach from=$Artikel->FunktionsAttribute key=key item=item}
   {assign var="key" value="{$key|replace:" ":"_"|escape:"url"|replace:"%F6":"oe"|replace:"%20":""|replace:"%DF":"ss"|replace:"%2F":"_"}"}
   {assign var=$key value={$item}}   
   {$key}<br>
{/foreach}


{$key}<br>:
Code:
groessenschema_s
schuhgroesse_s
etc ...




Now I want to put these together again.
Code:

{assign var=array value=['Größenscheme:' => 'groessenschema_s',
                         'Schuhgröße:' => 'schuhgroesse_s'
            ]
}

{foreach from=$array key=key item=item}
      {${$item}} : {key}                   <= failed
      ${$item}   : {key}                   <= failed
{/foreach}


How do I put a variable from a variable name together?
Thanks !!!
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1055

PostPosted: Tue Jan 31, 2017 1:18 pm    Post subject: Reply with quote

You must use same encoding for your templates and for your PHP source files. Once these match, your issue will disappear.
Back to top
View user's profile Send private message
lord_icon
Smarty n00b


Joined: 31 Jan 2017
Posts: 3

PostPosted: Tue Jan 31, 2017 1:22 pm    Post subject: Reply with quote

How can I query this?
Is indeed a foreign code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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