Page 1 of 1

First bit of smarty

Posted: Wed Mar 25, 2009 3:18 pm
by cowtan
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.

Re: First bit of smarty

Posted: Mon Jun 01, 2009 6:44 pm
by zappodrom
Hi cowtan,

I was searching for a solution you posted out here. For me the best way was to put only  {$cgsimple->get_root_alias()} at the right point to show the Name of the parent page.
Maybe it's something for you too.