Hi all:

I am a noob of Drupal and the question might be simple, but help me please.
My issue is I need to display the current menu title on a special space, but I have no idea how to call this variable.
For example: If I call $menu_get_active_title() then it will show the title of current page, but what I need is the menu title.
I draw a tree map to help you understand me as below:
a
a/b
a/c
a/c/d
a/e
a/f

If I am under a/c/d and call $title probably I will get the page title of a/c/d, but what I need is the TEXTURE of "a".
I did search in forum but what I got is a little bit beyond my lvl, Please explain more detailed ~~~ TY

Comments

nevets’s picture

I think this will help

<?php
$tree = menu_get_active_trail();
print $tree[1]['title'];
?>
kelvinc’s picture

First of all, thank you for ur reply
but it doent work and it still just displays the current page title;
when I click a/b/c, it still shows the title of "c" but not "a"

nevets’s picture

Ok I have 'a' as a parent of 'b' and 'b' a parent of 'c'. I made 'c' with a body of

<?php
$tree = menu_get_active_trail();
print $tree[1]['title'];
?>

with input format set to "PHP code" and it works fine.
If you make a 'c' with a body of (again using an input format of "PHP code")

<pre>
<?php
$tree = menu_get_active_trail();
print print_r($tree, TRUE);
?>
</pre>

what do you see?

kelvinc’s picture

when I put that code in "b" (a is menu1, b is a's leaf which is a page. I need title of "a") it shows :

Array ( [0] => Array ( [title] => Home [href] => [localized_options] => Array ( ) [type] => 0 ) [1] => Array ( [path] => node/% [load_functions] => Array ( [1] => node_load ) [to_arg_functions] => [access_callback] => node_access [access_arguments] => a:2:{i:0;s:4:"view";i:1;i:1;} [page_callback] => node_page_view [page_arguments] => Array ( [0] => stdClass Object ( [nid] => 21 [type] => page [language] => [uid] => 1 [status] => 1 [created] => 1226369268 [changed] => 1227146048 [comment] => 0 [promote] => 0 [moderate] => 0 [sticky] => 0 [tnid] => 0 [translate] => 0 [vid] => 21 [revision_uid] => 1 [title] => Complaints Process [body] =>

[log] => [revision_timestamp] => 1227146048 [format] => 3 [name] => admin [picture] => [data] => a:1:{s:18:"admin_compact_mode";b:1;} [last_comment_timestamp] => 1226369268 [last_comment_name] => [comment_count] => 0 [taxonomy] => Array ( ) [build_mode] => 0 [readmore] => ) ) [fit] => 2 [number_parts] => 2 [tab_parent] => [tab_root] => node/% [title] => Complaints Process [title_callback] => node_page_title [title_arguments] => a:1:{i:0;i:1;} [type] => 4 [block_callback] => [description] => [position] => [weight] => 0 [file] => [href] => node/21 [options] => Array ( ) [access] => 1 [localized_options] => Array ( ) [map] => Array ( [0] => node [1] => stdClass Object ( [nid] => 21 [type] => page [language] => [uid] => 1 [status] => 1 [created] => 1226369268 [changed] => 1227146048 [comment] => 0 [promote] => 0 [moderate] => 0 [sticky] => 0 [tnid] => 0 [translate] => 0 [vid] => 21 [revision_uid] => 1 [title] => Complaints Process [body] =>

[log] => [revision_timestamp] => 1227146048 [format] => 3 [name] => admin [picture] => [data] => a:1:{s:18:"admin_compact_mode";b:1;} [last_comment_timestamp] => 1226369268 [last_comment_name] => [comment_count] => 0 [taxonomy] => Array ( ) [build_mode] => 0 [readmore] => ) ) ) )

nevets’s picture

Ok, when I tried this I made three nodes of type 'page', one each for 'a', 'b' and 'c'. I made menu entry for 'a' in navigation, I then added 'b' in the menu as child of 'a' and 'c' as a child of 'b'. So in your trace the node with nid 21 is a menu entry that has not parent and has a title of 'Complaints Process'. The way I set things up I would expect that to correspond with 'a' but it seems to correspond with 'b' for you. So have you set up the menu differently or are you playing with the menu path?

kelvinc’s picture

My case is like:
block1---------------
| Login
| Products
| Contact us(a)
| ------------- Contact us(b)
| ------------- Complain Process(c)
|

"a" is a menu, b and c are items in menu "a", but "a" and "b" share the same node (page1) and c points to another node(page2).
that's how I set up the menu.

arthurhanlon’s picture

My personal logic dictates that the Contact Us page be the parent and the Complain Process is a child of that as it's within the "scope" of contacting a company, no?

I'm not sure I understand why you would arrange your menu to function like that but forgive me if I misunderstand the goals here.

Arthur

kelvinc’s picture

My task is to make an identical website of the corrent one.......In this case, it is not a perfect design, but that's not my business the moment.