First bit of smarty

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
cowtan
Forum Members
Forum Members
Posts: 70
Joined: Mon Jan 19, 2009 5:04 pm

First bit of smarty

Post 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.
User avatar
zappodrom
Forum Members
Forum Members
Posts: 91
Joined: Wed Apr 23, 2008 11:38 am

Re: First bit of smarty

Post 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.
Regards,
Christian

----
[X] <--- Nail here for new Monitor!
Post Reply

Return to “Tips and Tricks”