Hi
Is it possible to get the menu text of the current page's parent?
i really need this urgently but cant seem to find a way to do it.
I can get the current page with {menutext} but i need its highest parent
Many Thanks
Capture menu text
Re: Capture menu text
Unfortunately, there is no quick way to do this. We're working on a better solution.
In the meantime... (untested code, so it might need tweaking)
Now the most straight forward answer, but it's the best we have right now. The hierarchy manager changes that will most likely be in 0.11.2 will make it process much easier.
In the meantime... (untested code, so it might need tweaking)
Code: Select all
global $gCms;
$menu_text = '';
#Get pageinfo object and current hierarchy
$paginfo =& $gCms->variables['pageinfo'];
$hierarchy =& $pageinfo->content_hierarchy;
#Take hierarchy and only find the first section of it
$parent = split('.', $hierarchy, 1);
$parent = $parent[0]; //Always returns an array
#Pad out the zeros so it matches what is stored in the db
$parent = str_pad($parent, 5, '0', STR_PAD_LEFT);
#Select that piece of content's menu text out of the database
$db =& $gCms->db;
$row =& $db->GetRow('select menu_text from ' . cms_db_prefix() . 'content where hierarchy = ?', array($parent));
#If there is a row returned, set the value
if (isset($row))
$menu_text = $row['menu_text'];
-
fadum
Re: Capture menu text
1.Typo of "paginfo"
2.It wouldnt seem to split, so i changed to explode
Works Just Great Now! Thanks Wishy!
2.It wouldnt seem to split, so i changed to explode
Works Just Great Now! Thanks Wishy!
Re: Capture menu text
Ah, yes, explode would be the right one. Glad it's working...
-
fadum
Re: Capture menu text
This no longer seems to work with the latest version, do you have another way please
Thanks
Thanks

