[SOLVED] How to print the title of the parent page?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
urheat
Forum Members
Forum Members
Posts: 243
Joined: Sat Oct 17, 2009 6:50 am

[SOLVED] How to print the title of the parent page?

Post by urheat »

I use the following code in the sidebar. If the menu has children, the title of the parent page (or should be) and the menu are visible:

Webpage:

Products
> Cars
> Bikes

The code:

Code: Select all

{if cgsimple::has_children(cgsimple::get_root_alias()) == 1}
<div class="navheading">{cgsimple::get_root_alias()}</div>
{menu start_level="2"}
{/if}
The problem is that as you can see, the heading of the menu is not the title of the parent page but the alias. How can I print the title of the parent page?
Last edited by urheat on Thu Jan 09, 2014 6:19 pm, edited 1 time in total.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: How to print the title of the parent page?

Post by velden »

I use the following code in the sidebar. If the menu has children, the title of the parent page (or should be) and the menu are visible:
I don't fully understand the question:
If the menu has children
Do you mean that the current page has siblings? Like for example this page: http://tinyurl.com/khk6pn5

But you would like to have the parent's title above the menu in the sidebar?

EDIT:
Not fully tested:

Code: Select all

{cgsimple::get_parent_alias($page_alias,'parent_alias')} {if !empty($parent_alias)}
<h2>{cgsimple::get_page_title($parent_alias)}</h2>
{menu start_level=2} {/if}
or

Code: Select all

{cgsimple::get_parent_alias($page_alias,'parent_alias')} {if !empty($parent_alias)}
{menu start_page=$parent_alias}
{/if}
Last edited by velden on Thu Jan 09, 2014 8:44 am, edited 1 time in total.
urheat
Forum Members
Forum Members
Posts: 243
Joined: Sat Oct 17, 2009 6:50 am

Re: How to print the title of the parent page?

Post by urheat »

I mean if the parent page have children, then the sidebar navigation is visible. I would like to print to the page the heading of the parent page. For example if the user is in the page Therapie (Groepen>Therapie), the navigation would look like this:

Groepen (<- the heading of the parent page)
>Therapie
>Trainingen
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: How to print the title of the parent page?

Post by velden »

Just edited my earlier post, not sure if you receive notification about that.
urheat
Forum Members
Forum Members
Posts: 243
Joined: Sat Oct 17, 2009 6:50 am

Re: How to print the title of the parent page?

Post by urheat »

velden wrote:Just edited my earlier post, not sure if you receive notification about that.
Thanks a lot!

I tried those, but they didn't work as I wished. In both suggestions, if user enters to the child page, the title changes to the title of the current page (child page).

This happened:

When user is in Groepen-page, the menu is following:
Groepen
>Therapie
>Trainingen



When user is in Therapie-page:
Therapie (<-- this should be now Groepen, the title of parent page)
>Therapie
>Trainingen
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: How to print the title of the parent page?

Post by velden »

Are you sure you used $parent_alias and NOT $page_alias in the code except for the one occurence in the first line?

Seams to work on my test-site. http://tinyurl.com/ob4wadm

Both examples are used on page 'test udt' and its two children (in the content area). As 'test udt' has no parent, there is no menu showed. Both child show the menu with parent title.
urheat
Forum Members
Forum Members
Posts: 243
Joined: Sat Oct 17, 2009 6:50 am

Re: How to print the title of the parent page?

Post by urheat »

Sorry Velden :( I asked poorly. I ment ROOT title. Not the parent title (well, sometimes root title is also parent).

But with your tips I got this working:

Code: Select all

<h2>{cgsimple::get_page_title(cgsimple::get_root_alias())}</h2>
And as you said, your code works perfectly if the title of the parent is needed!
Last edited by urheat on Thu Jan 09, 2014 6:19 pm, edited 2 times in total.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: How to print the title of the parent page?

Post by JohnnyB »

Please add [Solved] to your Subject if everything worked out. Thanks!
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Post Reply

Return to “Modules/Add-Ons”