Album tree

juro_6

Joined: 2007-08-06
Posts: 2
Posted: Sun, 2008-01-27 17:41

Hi,

I have the following structure (quite simple):

Gallery root
  |- album 1
  |- album 2
     |- album 2_1
     |- album 2_2
  |- album 3
  etc ...

In my custom theme (based on slider, but not related any more :) ), I need a structure like this:

album 2 (link if not in this one)
<show subalbums> (this triggers an Ajax event to show the next div)
album 2_1 (link if not in this one)
album 2_2 (link if not in this one)

Now, I can get this from the album 2, but when I am in the album 2_1 or 2_2, I can iterate over the children of the parent. How can I access them?

This is what I have tried:

{assign var=parentCount value=0}
{section name=parent loop=$theme.parents}
	{if !$smarty.section.parent.first}
	  {assign var=parentCount value="`$parentCount+1`"}
	{/if}
{/section}

<ul class="album-nav">
  {if $parentCount == 0}
    {* in the root subalbum *}
    <li>{$theme.item.title|default:$theme.item.pathComponent|markup:strip}</li> {* name of root subalbum *}
  {else}
    {* in a subfolder of the root subalbum *}
    <li>
      <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.parents[1].id`" arg3="highlightId=`$theme.item.id`"}">
        {$theme.parents[1].title|default:$theme.parents[1].pathComponent|markup:strip}
      </a>
    </li>
    {* now add the subalbum navigation *}
    <li>
      <a href="" onclick="$('#stories').toggle(); return false;">story of the wedding</a>
      <ul id="stories" class="subalbum-nav">
        <!-- children of {$theme.parent.title} ... {$theme.parent|@print_r} -->
        {foreach from=$theme.parent.children item=child}
          <!-- children of {$child.title} -->
          {if $child.canContainChildren || $child.entityType == 'GalleryLinkItem'}
            <li>
              <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">
                {$child.title|markup:strip}
              </a>
            </li>
          {/if}
        {/foreach}
      </ul>
    </li>
  {/if}
</ul>

but it doesn't work as $theme.parent.children is always 0.
Any ideas why?