Page 1 of 1

Quick smarty help

Posted: Thu May 26, 2005 3:33 am
by JayBird
i have this array

Code: Select all

Array
(
    ї4] => Array
        (
            ї0] => Array
                (
                    їid] => 2
                    їfile_name] => test2
                    їfile_title] => kjdhfjh
                    їfile_type] => xls
                    їsection] => 4
                    їsub_section] => 4
                    їlast_updated] => 
                )

            ї1] => Array
                (
                    їid] => 1
                    їfile_name] => testfile
                    їfile_title] => testing1
                    їfile_type] => pdf
                    їsection] => 4
                    їsub_section] => 4
                    їlast_updated] => 
                )

        )

    ї5] => Array
        (
            ї0] => Array
                (
                    їid] => 3
                    їfile_name] => sdfsdf
                    їfile_title] => sdfsdf
                    їfile_type] => doc
                    їsection] => 4
                    їsub_section] => 5
                    їlast_updated] => 
                )

        )

)
How would i go about looping each level of the array using the {section} operator of smarty.

So i would get output like

Code: Select all

Section 4
   file1
   file2

Section 5
   file3
Thanks

Posted: Thu May 26, 2005 5:59 am
by JayBird
Never mind, done it myself

Code: Select all

{foreach from=$documents key=cid item=categories} 
{$cid} 

      {section name=files loop=$categories} 
       
         {$categoriesїfiles].file_name} 
          
      {/section} 
       
       
{/foreach}

Posted: Thu May 26, 2005 6:44 am
by neophyte
Thanks for the post pimptastic. I've wondered that a time or two myself.

Posted: Thu May 26, 2005 6:52 am
by JayBird
Only took me 2 hours to figure it out this morning...LOL. :D

So simple really :oops: