Howdy,
I've ripped this lovely piece of code out of the breadcrumb template and am using it in a custom theme I'm working on.
Problem is, I want to modify it to show the top-most parent album the user is currently in, on the level below the root.
I'm use to using i++ type counts in foreach loops to help me select the depth of the loop I want -- perhaps someone can think of an alternate solution, as I'm not sure how to go about doing this with Smarty
This code displays the album name with hyperlink of the level above the current view:
{foreach name=parent from=$theme.parents item=parent}
{if $smarty.foreach.parent.last}
<a href="{g->url params=$parent.urlParams}"> view images from {$parent.title|markup:strip|default:$parent.pathComponent}</a>
{/if}
{/foreach}
Posts: 23886
I don't understand.
What if the user is on the root album-> What should it show?
What if the user is one the level below the root-> What should it show?
What is the user is 4 levels deep what level-> What should it show?
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 112
Hi there,
Nothing -- either a different template for the root will be used or this will be done via code
It would still show the topmost level of the tree, below the root
I'm using my Gallery for countries and cities. When a person is on the level below the root, or 4 levels deep, I'd still like to reference the name of the country they are in. It doesn't have to include the hyperlink to the album, just the album name will do.
Posts: 23886
Still a bit confused but; I think this is what you are after:
{foreach name=parent from=$theme.parents item=parent} {if $smarty.foreach.parent.iteration ==2} <a href="{g->url params=$parent.urlParams}">{$parent.title|markup:strip|default:$parent.pathComponent}</a> link to first child from parent {/if} {/foreach}Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 112
This is exactly the Smarty syntax I was looking for -- works perfectly on all albums lower than the first under the root.
..that is to say:
I still need the name of the album at the "album 1" level -- thoughts on how that can be captured in conjunction with the current ==2 functionality?
Posts: 112
I've got a good working concept of this now, but could use the code snippet that displays the current album the visitor is in.
Thanks for the brain power!
Posts: 23886
Enable FAQ: How to set/use Gallery in debug mode? and in the popup you will see all the smarty variable available for the page you are on.
A smarty debug console will popup showing all the data available to that page (make sure your browser allows popups, at least for your server's domain). To access this data connect the names at each level of indentation with dots.. some examples with some modifiers added:
{$theme.item.title}
{$theme.parent.title|markup:strip} {$theme.item.title|default:$theme.item.pathComponent|markup:strip} {$user.username} {$theme.item.height) {$theme.item.width}
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 112
That looks great Dave, thank you.
Reference for others, the (reduced) code block looks like this:
{foreach name=parent from=$theme.parents item=parent} {if $smarty.foreach.parent.total ==1} {* DISPLAY CURRENT ALBUM TITLE *} {$theme.item.title|default:$theme.item.pathComponent|markup:strip} {elseif $smarty.foreach.parent.iteration ==2} {* DISPLAY FIRST CHILD AFTER ROOT OF CURRENT ALBUM TREE *} {$parent.title|markup:strip|default:$parent.pathComponent} {/if} {/foreach}Posts: 23886
Glad you got it sorted and thanks for posting back code for others.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team