Page 1 of 1

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

Posted: Thu Jan 09, 2014 7:42 am
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?

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

Posted: Thu Jan 09, 2014 8:28 am
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}

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

Posted: Thu Jan 09, 2014 8:36 am
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

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

Posted: Thu Jan 09, 2014 8:47 am
by velden
Just edited my earlier post, not sure if you receive notification about that.

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

Posted: Thu Jan 09, 2014 12:37 pm
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

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

Posted: Thu Jan 09, 2014 12:50 pm
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.

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

Posted: Thu Jan 09, 2014 12:53 pm
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!

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

Posted: Thu Jan 09, 2014 3:22 pm
by JohnnyB
Please add [Solved] to your Subject if everything worked out. Thanks!