Page 1 of 1
Title for ELLNav H/V menu
Posted: Fri May 19, 2006 11:25 am
by Ken
Hi,
I would like to know if ELLNav H/V allows to get a title at top of vertical menu?
This title would be parent level menu_text!
I've found a topic speaking about this but with no answer.
http://forum.cmsmadesimple.org/index.ph ... ml#msg7404
Solution would be a tag with code below. Could this be validated by CMSMS guru
global $gCms;
global $db;
$vars = $gCms->variables;
$query = "SELECT content_name FROM ".cms_db_prefix()."content WHERE content_id = (SELECT parent_id FROM ".cms_db_prefix()."content WHERE content_id = '".$vars['content_id']."');";
$dbresult = $db->Execute($query);
if ($dbresult && $dbresult->RowCount() > 0) {
$row = $dbresult->FetchRow();
echo $row['content_name'];
}
Thanks for help
Re: Title for ELLNav H/V menu
Posted: Sat May 20, 2006 6:23 pm
by Ted
Well, it would need a slight modification. Put this code into a user-defined tag. Call it parent_title.
Code: Select all
global $gCms;
$db =& $db->GetDb();
$vars =& $gCms->variables;
$query = "SELECT content_name FROM ".cms_db_prefix()."content WHERE content_id = (SELECT parent_id FROM ".cms_db_prefix()."content WHERE content_id = '".$vars['content_id']."');";
$dbresult = $db->Execute($query);
if ($dbresult && $dbresult->RowCount() > 0) {
$row = $dbresult->FetchRow();
echo $row['content_name'];
}
Then put this tag ({parent_title}) pretty much anywhere, either content/template or menu manager template.
Re: Title for ELLNav H/V menu
Posted: Sat May 20, 2006 9:10 pm
by Ken
Hi Ted ... thank you for your very quick answer.
When I tried code you posted, I got :
Fatal error: Call to a member function on a non-object in c:\program files\easyphp1-8\www\lib\content.functions.php(653) : eval()'d code on line 2
(I'm still working locally with easyPHP 1.8.0.1 and I'm testing release 0.13-beta4)
The code found on the forum gives no error message but doesn't work properly as ...
I'm working with 3 levels
- first level with H menu
- second and third with V menu.
I would like to get the menu_text (or title) of [glow=red,2,300]LEVEL 1[/glow] at the top of V menu.
Code found on the forum doesn't do that and yours gives an error I don't understand.
Last question. What's the best way to customize this menu title with CSS?
Thx again
Re: Title for ELLNav H/V menu
Posted: Sat May 20, 2006 9:38 pm
by Ted
Sorry, there was a typo in line 2.
Code: Select all
global $gCms;
$db =& $gCms->GetDb();
$vars =& $gCms->variables;
$query = "SELECT content_name FROM ".cms_db_prefix()."content WHERE content_id = (SELECT parent_id FROM ".cms_db_prefix()."content WHERE content_id = '".$vars['content_id']."');";
$dbresult = $db->Execute($query);
if ($dbresult && $dbresult->RowCount() > 0) {
$row = $dbresult->FetchRow();
echo $row['content_name'];
}
You'll want to wrap the output of this plugin in a div or span or something that you can give an id to. Then you can just style it with css normally.
Re: Title for ELLNav H/V menu
Posted: Sun May 21, 2006 4:08 pm
by Ken
Hi Ted ... Thank you
No error message now ... but (sorry about that) code doesn't work properly as the idea is :
- to get the menu_text (or title) from H menu (level 1) ...
- ... above V menu (2nd and 3rd level) ...
- ... when item at V menu (Level 1) is selected.
Current code is giving parent_title. Then Title does appear only if we click on an item of 2nd level and not at the same time as V menu appears.
[attachment deleted by admin]
Re: Title for ELLNav H/V menu
Posted: Mon May 22, 2006 1:16 pm
by mikemee
This was a GREAT thread.
Trying to give a bit back, I've added it as a FAQ entry at
http://wiki.cmsmadesimple.org/index.php ... nu_Heading.
thanks again!
Re: Title for ELLNav H/V menu
Posted: Mon May 22, 2006 1:32 pm
by Ken
Hi mikemee
Sure it is but not working properly yet.
It will be much more sexy when item from first level appears above V menu when we click on this item.
You see what I mean? Sorry for my English.
I hope Ted will have a few seconds to sort it out as I do know nothing in php!
Re: Title for ELLNav H/V menu
Posted: Thu May 25, 2006 12:10 pm
by mikemee
I think I understand the problem and have a possible solution.
The problem is that you're still at the 1st level when you've clicked on the 1st menu, so there is no parent_title to display yet. But after clicking on the 2nd level menu, now parent_title becomes the first level title and displays as expected. To fix it, we need to detect the lack of result and use the current level.
In short, the following code will work as you expect:
Code: Select all
global $gCms;
$db =& $gCms->GetDb();
$vars =& $gCms->variables;
$query = "SELECT content_name FROM ".cms_db_prefix()."content WHERE content_id = (SELECT parent_id FROM ".cms_db_prefix()."content WHERE content_id = '".$vars['content_id']."');";
$dbresult = $db->Execute($query);
if ($dbresult && $dbresult->RowCount() > 0) {
$row = $dbresult->FetchRow();
echo $row['content_name'];
} else {
echo $vars['pageinfo']->content_menutext;
}
Note the last three lines have changed by adding an else. (It took 10 mins of digging around the source code to find the menutext to return - my first exploration of cmsms code - but I learnt a lot

).
Hope this fixes your problem!
Re: Title for ELLNav H/V menu
Posted: Wed May 31, 2006 11:46 pm
by Ken
Yes ... you did it !

That's cool ! Just one little thing. It should be better if parent_title doesn't appear if there is nothing in the submenu
Well done .. many thx for your help !