×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Smarty: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
    imported>mutante
    mNo edit summary
    Line 10: Line 10:


    oder listen machen mit:<pre><table><tr><td>nr</td><td>name</td></tr> {foreach item=foo from=$var</pre>
    oder listen machen mit:<pre><table><tr><td>nr</td><td>name</td></tr> {foreach item=foo from=$var</pre>

    Auch unterstützt Smarty den Designer indem es 'includes' ermöglicht. So braucht man nicht immer den gesamten Quellcode in eine Datei packen, sondern in der .tpl-datei die dann am ende des php-code "aktiviert" wird steht oben {include file="kopf.tpl"} und unten analog fuss.tpl und ggf zb auch
    {include file="menu.tpl" aktiv="seite23"}

    (im template menu.tpl kann dann mit {if aktiv=="SeiteX"}<div=highlight>{/if} oder so der entsprechende eintrag hervor

    sehr nett sind auch so sachen wie <pre><a href="/foo/bar/user_{$name|urlencode}>{$name}</a></pre>

    ---



    "One of Smartys primary design goals is to facilitate the separation of application code from presentation. Typically, the application code is maintained by programmers. The presentation templates are maintained by template designers."
    "One of Smartys primary design goals is to facilitate the separation of application code from presentation. Typically, the application code is maintained by programmers. The presentation templates are maintained by template designers."

    Revision as of 19:25, 24 October 2006

    Smarty ist eine recht stark verbreitete und dadurch ziemlich ausgereifte open source template engine für PHP.

    Man setzt im PHP-Quellcode nur noch Werte die der Designer dann später leicht nutzen kann. zb so:

    $Smarty->assign("varnamefuertemplate", $phpvariable);
    

    (wobei $phpvariable auch zB ein array sein kann). im template (extra files, die auf .tpl enden und hauptsächlich reinen HTML-code enthalten) kann man dann z.b. schreiben:

    "Hallo {$name}, du bist eingelogt"
    

    oder listen machen mit:

    <table><tr><td>nr</td><td>name</td></tr> {foreach item=foo from=$var

    Auch unterstützt Smarty den Designer indem es 'includes' ermöglicht. So braucht man nicht immer den gesamten Quellcode in eine Datei packen, sondern in der .tpl-datei die dann am ende des php-code "aktiviert" wird steht oben {include file="kopf.tpl"} und unten analog fuss.tpl und ggf zb auch

    {include file="menu.tpl" aktiv="seite23"}
    

    (im template menu.tpl kann dann mit {if aktiv=="SeiteX"}<div=highlight>{/if} oder so der entsprechende eintrag hervor

    sehr nett sind auch so sachen wie

    <a href="/foo/bar/user_{$name|urlencode}>{$name}</a>

    ---


    "One of Smartys primary design goals is to facilitate the separation of application code from presentation. Typically, the application code is maintained by programmers. The presentation templates are maintained by template designers."


    Template loop detected: Template:Stub

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.