Quick smarty help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Quick smarty help

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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}
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Thanks for the post pimptastic. I've wondered that a time or two myself.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Only took me 2 hours to figure it out this morning...LOL. :D

So simple really :oops:
Post Reply