Smarty Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Red

    Smarty Problem

    Hello

    I have a Smarty(.php.net ) Question.

    I want to create a Navigation with a Smarty Template.

    How can I display an Array recursively?
    Do I have to write a Plugin?


    Exmp.


    Array
    (
    [0] => Array
    (
    [Text] => "Item 1"
    [Childs] => Array
    (
    [0] => Array
    (
    [Text] => "Item 1.1"
    [Childs] => Array
    (
    [0] => Array
    (
    [Text] => "Item 1.1.1"
    )
    [1] => Array
    (
    [Text] => "Item 1.1.2"
    )
    )
    )
    [1] => Array
    (
    [Text] => "Item 1.2"
    [Childs] => Array
    (
    [0] => Array
    (
    [Text] => "Item 1.2.1"
    )
    [1] => Array
    (
    [Text] => "Item 1.2.2"
    )
    )
    )
    )
    )
    [1] => Array
    (
    [Text] => "Item 2"
    [Childs] => Array
    (
    [0] => Array
    (
    [Text] => "Item 2.1"
    )
    )
    )
    )



    Something like this
    -------------------

    {navigation item=item from=$array}
    <td>{$item.text }</td>
    {/navigation}


    Best Regards

    Jim
  • Ian.H

    #2
    Re: Smarty Problem

    On Tue, 14 Sep 2004 14:45:49 +0200, Jim Red <jimred73@hotma il.com>
    wrote:
    [color=blue]
    >Hello
    >
    >I have a Smarty(.php.net ) Question.
    >
    >I want to create a Navigation with a Smarty Template.
    >
    >How can I display an Array recursively?
    >Do I have to write a Plugin?
    >
    >
    >Exmp.
    >
    >
    >Array
    >(
    > [0] => Array
    > (
    > [Text] => "Item 1"
    > [Childs] => Array
    > (
    > [0] => Array
    > (
    > [Text] => "Item 1.1"
    > [Childs] => Array
    > (
    > [0] => Array
    > (
    > [Text] => "Item 1.1.1"
    > )
    > [1] => Array
    > (
    > [Text] => "Item 1.1.2"
    > )
    > )
    > )
    > [1] => Array
    > (
    > [Text] => "Item 1.2"
    > [Childs] => Array
    > (
    > [0] => Array
    > (
    > [Text] => "Item 1.2.1"
    > )
    > [1] => Array
    > (
    > [Text] => "Item 1.2.2"
    > )
    > )
    > )
    > )
    > )
    > [1] => Array
    > (
    > [Text] => "Item 2"
    > [Childs] => Array
    > (
    > [0] => Array
    > (
    > [Text] => "Item 2.1"
    > )
    > )
    > )
    >)
    >
    >
    >
    >Something like this
    >-------------------
    >
    >{navigation item=item from=$array}
    > <td>{$item.text }</td>
    >{/navigation}
    >
    >
    >Best Regards
    >
    >Jim[/color]


    There's {section} and {foreach} you could try.. unless you specifically
    wanted to write a {navigation} plugin.

    You might also need to make use of {assign} to assign some arrays
    temporarily through the stages, inwhich case, a plugin maybe a better
    solution as per your specific requirements.

    You might also get better / more concise opinions / solutions posting on
    the forum at <http://smarty.php.net/>. Some helpful people there too
    "specifical ly" involved in Smarty =)



    Regards,

    Ian

    --
    Ian.H
    digiServ Network
    London, UK

    Comment

    Working...