遍历pyrocms模板变量中的数组

I've adapted the File plugin to list all folders and inside of them list all files.

The code is more or les like this:

$folders = assoc_array_prop($this->file_folders_m->get_all());
$counter = 1;
foreach ($folders as $key => $folder) {
$folder->index = str_pad($counter++, 2, '0', STR_PAD_LEFT);
$this->file_m->where('folder_id', $folder->id);
$files = $this->file_m->get_all();
$folder->files = assoc_array_prop($files);
}
return $folders;

Now, the thing is, how can I access each $folder->files for each folder in the template? This doesn't seem to work:

{pyro:mymod:file_listing}
    <div class="files_column">
    <h2><span class="files-index">&#123;index}</span> &#123;name}</h2>
{pyro:files}


<div class="file-item">

<span class="file-type">{id}</span>

<div class="file-data">
<span>{filename}</span>
<br/>
<span class="file-links">
<a href="#">View</a>
<a href="#">Download</a>
</span>

</div>
</div>
{/pyro:files}


</div>
{/pyro:mymod:file_listing}

To clarify on this... the {files} loop seems to work ok, based on the number of times I see the data appear. The problem is that I can't seem to acces its attributes, like {filename}.

Thanks, Ignacio

first thing I think you're doing wrong is having the inner pyro tag {pyro:files} which I'm pretty sure will just call the core pyro:files plugin.

What I did to do a form of traversing that didn't otherwise seem possible with tags was to use attributes of the outer tag to find information for the inner tag:

like this:

{pyro:movies:now_showing}

<img src="{img_path}"/>
<p>{pyro:movies:synopsis_snippet id="{movie_id}" length="100"}</p>

{/pyro:movies:now_showing}

so I used the movie_id from the current element to get another piece of data from my plugin. My plugin has a now_showing and a synopsis_snippet function.

What you could do is have a method that lists folders and one that lists files of a folder something like this:

{pyro:my_plugin:folders}

{pyro:my_plugin:list_files_of_folder id="{attribute to lookup folder}"}
{/pyro:my_plugin:list_files_of_folder}

{/pyro:my_plugin:folders}

Hope this helps. :)