Yes there is, two ways, I'll show the easier (template-smarty) approach:
Add this in your album.tpl file:
{assign var="hasDataItems" value=0}
{foreach from=$theme.children item=child}
{if !$child.canContainChildren}
{assign var="hasDataItems" value=1}
{/if}
{/foreach}
{if ($hasDataItems == 1)}
Has data items
{else}
Has only albums
{/if}
When an album only has albums it will show "Has only albums". Instead of that text you can add any templat code you want...
[edit]When there are 0 subitems (either labums or dataitems) the text will still say "Has only albums" even though there are none. You can use $theme.childCount to test if there are any child items at all.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-09-18 13:58
in theme.inc in showAlbumPage(), you have to do something like:
then in the templates (album.tpl), use {if $theme.hasOnlySubAlbums} or something like that.
RwD
Joined: 2005-01-09
Posts: 383
Posted: Sun, 2005-09-18 14:05
Valiants approach is the other one I had in mind :P
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-09-18 14:10
hey RwD, thanks for all the support here in the forums!
Feel free to add howto's or links on the user contributions page in the codex anytime. then you can just link to the codex instead of writing stuff multiple times.
and how to check if the subalbums of the current album has any child or not?
(eg. to hide emtpy subalbums)
RwD
Joined: 2005-01-09
Posts: 383
Posted: Fri, 2006-03-03 09:52
joe7rocks wrote:
and how to check if the subalbums of the current album has any child or not?
(eg. to hide emtpy subalbums)
Not quite sure. But I do know how to check for subalbums inside the templates.
{foreach from=$theme.children item=child}
{if empty($theme.tree[$child.id])}
{$child.title} has no subalbums
{else}
{$child.title} does have subalbums
{/if}
{/foreach}
I do not think this specific piece of code can be expanded to include checking for dataitems and linkitems. But I do think it is a start ;)
Posts: 383
Yes there is, two ways, I'll show the easier (template-smarty) approach:
Add this in your album.tpl file:
{assign var="hasDataItems" value=0} {foreach from=$theme.children item=child} {if !$child.canContainChildren} {assign var="hasDataItems" value=1} {/if} {/foreach} {if ($hasDataItems == 1)} Has data items {else} Has only albums {/if}When an album only has albums it will show "Has only albums". Instead of that text you can add any templat code you want...
[edit]When there are 0 subitems (either labums or dataitems) the text will still say "Has only albums" even though there are none. You can use $theme.childCount to test if there are any child items at all.
Posts: 32509
in theme.inc in showAlbumPage(), you have to do something like:
$theme['hasOnlySubAlbums'] = true; $theme['subalbums'] = array(); foreach ($theme['children'] as $child) { if (isset($child['canContainChildren'] && $child['canContainChildren']) { $theme['subalbums'][] = $child; } else { $theme['hasOnlySubAlbums'] = false; } } }then in the templates (album.tpl), use {if $theme.hasOnlySubAlbums} or something like that.
Posts: 383
Valiants approach is the other one I had in mind :P
Posts: 32509
hey RwD, thanks for all the support here in the forums!
Feel free to add howto's or links on the user contributions page in the codex anytime. then you can just link to the codex instead of writing stuff multiple times.
thanks again for your effort!
Posts: 15
thanks a lot
Posts: 383
Ok, I added my latest two posts to the codex http://codex.gallery2.org/index.php/Gallery2:UserContributions#Mods.2FPatches .
Posts: 556
and how to check if the subalbums of the current album has any child or not?
(eg. to hide emtpy subalbums)
Posts: 383
Not quite sure. But I do know how to check for subalbums inside the templates.
{foreach from=$theme.children item=child} {if empty($theme.tree[$child.id])} {$child.title} has no subalbums {else} {$child.title} does have subalbums {/if} {/foreach}I do not think this specific piece of code can be expanded to include checking for dataitems and linkitems. But I do think it is a start ;)