First bit of smarty
Posted: Wed Mar 25, 2009 3:18 pm
I'm pretty new to cms and I'm still very much finding my way - I'm also very new to smarty. I've just written my first small chunk of smarty. This checks to see if the current page is a child, and if it is, it finds the title of the parent and displays that, if it isn't a child, it displays the title of the current page.
{$cgsimple->get_parent_alias('','parentAlias')}
{if $parentAlias}
{foreach from=$nodelist item=node}
{if $node->alias == $parentAlias}
{$node->pagetitle}
{/if}
{/foreach}
{else}
{title}
{/if}
It took me a good couple of hours to work out how to do this, and I feel older and wiser as a result but... I wouldn't be at all surprised if there was an easier way. So, I'm asking if anyone knows of a better way to do this, let me know.
{$cgsimple->get_parent_alias('','parentAlias')}
{if $parentAlias}
{foreach from=$nodelist item=node}
{if $node->alias == $parentAlias}
{$node->pagetitle}
{/if}
{/foreach}
{else}
{title}
{/if}
It took me a good couple of hours to work out how to do this, and I feel older and wiser as a result but... I wouldn't be at all surprised if there was an easier way. So, I'm asking if anyone knows of a better way to do this, let me know.