• Kontakt
  • O systemie
  • Strona główna
Pomoc
  • Założenia systemu
  • Praca z systemem
  • Opcje
  • Szablony
    • Podstawy składni Smarty
      • Komentarze
      • Zmienne
      • Operacje matematyczne
      • Pętla {foreach},{foreachelse}
      • Instrukcje warunkowe
      • Dyrektywa {include}
      • Pętle {section},{sectionelse}
      • Polecenie przypisanie {assign}
      • Modyfikatory
      • Inne funkcje
    • Smarty w systemie Actualizer CMS
  • Moduły
  • Edytor HTML
  • E-commerce - sprzedaż online
  • Inne zagadnienia
  • Przykłady rozwiązań

Modyfikatory

Pozwalają formatować, modyfikować zmienne.

Modyfikator default – wartość domyślna

Zmienna $myTitle jest pusta:

{$articleTitle|default:"no title"}
{$myTitle|default:"no title"}

Powyższy przykład wygeneruje:

Dealers Will Hear Car Talk at Noon.
no title

Modyfikator escape – znaki specjalne

Wartość zmiennej $articleTitle

$articleTitle = 'Stiff Opposition Expected to Casketless Funeral Plan'

$EmailAddress = 'smarty@example.com'

Szablon:

{$articleTitle}
{$articleTitle|escape}
{$articleTitle|escape:'html'} {* escapes & " ' < > *}
{$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
{$articleTitle|escape:'url'}
{$articleTitle|escape:'quotes'}
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
{$EmailAddress|escape:'mail'} {* this converts to email to text *}
{'mail@example.com'|escape:'mail'}

Powyższy przykład wygeneruje:

'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
'Stiff Opposition Expected to Casketless Funeral Plan'
%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27
\'Stiff Opposition Expected to Casketless Funeral Plan\'
<a href="mailto:%62%6f%..snip..%65%74">bob..snip..et</a>
smarty [AT] example [DOT] com
mail [AT] example [DOT] com


Modyfikator lower – konwersja do małych liter

{$articleTitle}
{$articleTitle|lower}

Powyższy przykład wygeneruje:

Two Convicts Evade Noose, Jury Hung.
two convicts evade noose, jury hung.

Modyfikator string_format – formatowanie wartości liczbowych

$number = 23.5787446


{$number}
{$number|string_format:"%.2f"}
{$number|string_format:"%d"}

Powyższy przykład wygeneruje:

23.5787446
23.58
24

Modyfikator strip – usuwanie “białych znaków”

$articleTitle = "Grandmother of\neight makes\t hole in one.";



{$articleTitle}
{$articleTitle|strip}
{$articleTitle|strip:" "}

Powyższy przykład wygeneruje:

Grandmother of
eight makes hole in one.
Grandmother of eight makes hole in one.
Grandmother of eight makes hole in one.

Modyfikator strip_tags – usuwanie tagów HTML


$articleTitle = "Blind Woman Gets <font face=\"helvetica\">New
Kidney</font> from Dad she Hasn't Seen in <b>years</b>.
";



{$articleTitle}
{$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *}
{$articleTitle|strip_tags:true}

Powyższy przykład wygeneruje:

Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years .
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.

Modyfikator truncate – ucinanie zbyt długich tekstów

$articleTitle = "Two Sisters Reunite after Eighteen Years at Checkout Counter.";


{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}

Powyższy przykład wygeneruje:

Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...

Modyfikator upper – konwersja do wielkich liter


{$articleTitle}
{$articleTitle|upper}

Powyższy przykład wygeneruje:

If Strike isn't Settled Quickly it may Last a While.
IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.

Powered by Actualizer CMS