I have never seen such a complex way of generating a navigation menu in my life. What I am trying to do, is generate the html code for a standalone D7 top menu, without any styling.... nothing but all the menu items enclosed appropriately in <ul> and <li> tags.
All of the top menu items are stored in database table sys_menu_top. They are in no particular order, and it is impossible to simply retrieve them from the DB and order them appropriately. You can get all the main menu items and order them appropriately, but there is no way to directly associate the sub menu items with the correct main menu item since the 'parent' field is a '0' for every item. To complicate things, the permalinks are stored in a separate table, 'sys_permalinks'.
So... I can't just grab the menu items from the db and construct a menu... can't be done. Had the sub menus items been assigned a main menu item as a parent, it could be done.
Instead, somewhere along the line, the cache/sys_menu_top.inc file is written... by some function of the menu builder I presume. Then you got the php class in inc/classes/BxDolMenu.php You got a javascript class in in/js/classes/BxDolMenu.js You got a file in templates/base/scripts/BxBaseMenu.php
Holy F@&%!! S@#%! All I want to do is generate a stupid menu. Surely, with all these database tables, php and javascipt classes flying around, there's got to be some incredibly easy way to do this.
WILL SOMEONE AT BOONEX PLEASE SHOW ME HOW TO DO THIS BEFORE I KILL MYSELF!!
Why do I want to do this? .... because if this is done, it gives everyone on the planet an easy way to add a dolphin top menu to any third party application and style it for that application.
I'll even get it started:
<?
Need the rest of the code here
?> My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Actually....
<?php
?>
Shorthand version:
<?
?>
http://www.w3schools.com/php/php_syntax.asp
:-) |
https://www.deanbassett.com |
great post, i have been looking for this solution from day one.
I am currently using the iframe for the 3rd part header. not good at all
|
Take a closer look Deano. All of the top menu main items have a parent number of '0'. There's no way to tell which submenu items belong to which main item just buy looking at this table. If the main items all had a 'Type' of 'Top", and the had a different parent number.... and the submenu items used the individual parent numbers..... THEN you could sort things out.....but that's not the way it is.
So.... it is impossible to use only this table to construct the top menu. You can determine the main menu item because the type is 'Top', but there is no way to directly associate the submenu items directly with the main menu item, just by looking at this table My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
I have never seen such a complex way of generating a navigation menu in my life. What I am trying to do, is generate the html code for a standalone D7 top menu, without any styling.... nothing but all the menu items enclosed appropriately in <ul> and <li> tags.
Here's what i've coded for you. This will generate the Menu in <ul> n <li> tag
Save it as any php file, upload n run
<?php
require_once( 'inc/header.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php' ); require_once( BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/scripts/BxTemplMenu.php" );
class SimpleMenu extends BxTemplMenu { function getCode() { $this->iElementsCntInLine = 100; $this->getMenuInfo(); $this->genTopItems(); return $this->sCode; }
function genTopItem($sText, $sLink, $sTarget, $sOnclick, $bActive, $iItemID, $isBold = false, $sPicture = '') { $sActiveStyle = ($bActive) ? ' id="tm_active"' : '';
if (!$bActive) { $s alt= $sOnclick ? ( ' alt="' . $sOnclick . '"' ) : ''; $sTarget = $sTarget ? ( ' target="' . $sTarget . '"' ) : ''; }
$sLink = (strpos($sLink, 'http://') === false && !strlen($sOnclick)) ? $this->sSiteUrl . $sLink : $sLink;
$sSubMenu = $this->getAllSubMenus($iItemID);
$sImgTabStyle = $sPictureRep = ''; if ($isBold && $sPicture != '') { $sPicturePath = getTemplateIcon($sPicture); $sPictureRep = "<img src='{$sPicturePath}' style='vertical-align:middle;width:16px;height:16px;' />"; $sText = ' '; $sImgTabStyle = 'style="width:38px;"'; }
$sMainSubs = ($sSubMenu=='') ? '' : " {$sSubMenu} </a>"; $this->sCode .= "<ul> <a href='{$sLink}' {$sOnclick} {$sTarget}>{$sPictureRep}{$sText}</a>{$sMainSubs} </ul>"; }
}
$objMenu = new SimpleMenu();
echo $objMenu->getCode();
?> Hope this is what you are trying to achieve
Kevin
Looking for Help? http://www.boonex.com/kevinmitnick |
Parse error: syntax error, unexpected T_STRING in /home/houstonl/public_html/SimpleMenu.php on line 22
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
YES! Thank you! ....just had to remove the inadvertent space on line 22. This makes you me new best friend :) My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
YES! Thank you! ....just had to remove the inadvertent space on line 22. This makes you me new best friend :)
Glad i can help :)
Looking for Help? http://www.boonex.com/kevinmitnick |
YES! Thank you! ....just had to remove the inadvertent space on line 22. This makes you me new best friend :)
My best friend also :)) I was looking for a solution on this menu for a long time!!!
I have a question tough, how can it be integrated into the template system? which is build only with .html? I mean I don't want any iframes.. but can't think of anything else to include a php file in html..
Cheers.
|
Yes, the top menu items have a parent of 0 which means its a top menu item. The ones that are not 0 is a submenu item and the parent id there is the id of the top menu item it belongs to.
The first item in my table is My Profile. Parent id is 0 so it's a top menu item. It's ID is 4. So to get all the sub menu items for that would be SELECT * from `sys_menu_top` where `Parent`= '4' order by `Order`;
So to construct the menu you would first need to obtain all the top menu items. then loop through each of those obtaining the sub menu items.
Anyhow. I see someone has given you code using built in dolphin functions.
But my point is it can be done from that table.
https://www.deanbassett.com |
This is pretty usefull stuff! thank you alot for posting!
NickL
|
YES! Thank you! ....just had to remove the inadvertent space on line 22. This makes you me new best friend :)
My best friend also :)) I was looking for a solution on this menu for a long time!!!
I have a question tough, how can it be integrated into the template system? which is build only with .html? I mean I don't want any iframes.. but can't think of anything else to include a php file in html..
Cheers.
Use Jquery's load function to load the menu from php file into your html file
$('#menu').load('pathto/SimpleMenu.php');
Looking for Help? http://www.boonex.com/kevinmitnick |
Here's what I ended up with after a few minor changes:
<?php
require_once( '../inc/header.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php' ); require_once( BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/scripts/BxTemplMenu.php" );
class SimpleMenu extends BxTemplMenu { function getCode() { $this->iElementsCntInLine = 100; $this->getMenuInfo(); $this->genTopItems(); return $this->sCode; }
function genTopItem($sText, $sLink, $sTarget, $sOnclick, $bActive, $iItemID, $isBold = false, $sPicture = '') { $sActiveStyle = ($bActive) ? ' id="tm_active"' : '';
if (!$bActive) { $salt= $sOnclick ? ( ' alt="' . $sOnclick . '"' ) : ''; $sTarget = $sTarget ? ( ' target="' . $sTarget . '"' ) : ''; }
$sLink = (strpos($sLink, 'http://') === false && !strlen($sOnclick)) ? $this->sSiteUrl . $sLink : $sLink;
$sSubMenu = $this->getAllSubMenus($iItemID);
$sImgTabStyle = $sPictureRep = ''; if ($isBold && $sPicture != '') { $sPicturePath = getTemplateIcon($sPicture); $sPictureRep = "<img src='{$sPicturePath}' style='vertical-align:middle;width:16px;height:16px;' />"; $sText = ' '; $sImgTabStyle = 'style="width:38px;"'; }
$sMainSubs = ($sSubMenu=='') ? '' : "<ul> {$sSubMenu} </a></ul>"; $this->sCode .= "<li> <a href='{$sLink}' {$sOnclick} {$sTarget}>{$sPictureRep}{$sText}</a>{$sMainSubs} </li>"; }
}
$objMenu = new SimpleMenu();
echo $objMenu->getCode();
?> Hope this is what you are trying to achieve
Kevin
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Then, with some code from dynamicdrive.com, I created menu.php Below is the code I used:
Demo: http://houstonlively.com/menu_test/menu.php
<html> <head>
<style type="text/css">
/*Credits: Dynamic Drive CSS Library */ /*URL: http://www.dynamicdrive.com/style/ */
.sidebarmenu ul{ margin: 0; padding: 0; list-style-type: none; font: bold 13px Verdana; width: 180px; /* Main Menu Item widths */ border-bottom: 1px solid #ccc; }
.sidebarmenu ul li{ position: relative; }
/* Top level menu links style */ .sidebarmenu ul li a{ display: block; overflow: auto; /*force hasLayout in IE7 */ color: white; text-decoration: none; padding: 6px; border-bottom: 1px solid #778; border-right: 1px solid #778; }
.sidebarmenu ul li a:link, .sidebarmenu ul li a:visited, .sidebarmenu ul li a:active{ background-color: #012D58; /*background of tabs (default state)*/ }
.sidebarmenu ul li a:visited{ color: white; }
.sidebarmenu ul li a:hover{ background-color: black; }
/*Sub level menu items */ .sidebarmenu ul li ul{ position: absolute; width: 170px; /*Sub Menu Items width */ top: 0; visibility: hidden; }
.sidebarmenu a.subfolderstyle{ background: url(right.gif) no-repeat 97% 50%; }
/* Holly Hack for IE \*/ * html .sidebarmenu ul li { float: left; height: 1%; } * html .sidebarmenu ul li a { height: 1%; } /* End */
</style>
<script type="text/ //By Dynamic Drive: http://www.dynamicdrive.com/style/
var menuids=["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas
function initsidebarmenu(){ for (var i=0; i<menuids.length; i++){ var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul") for (var t=0; t<ultags.length; t++){ ultags[t].parentNode.getElementsByTagName("a")[0].className+=" subfolderstyle" if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item else //else if this is a sub level submenu (ul) ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it ultags[t].parentNode. alt=function(){ this.getElementsByTagName("ul")[0].style.display="block" } ultags[t].parentNode. alt=function(){ this.getElementsByTagName("ul")[0].style.display="none" } } for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars ultags[t].style.visibility="visible" ultags[t].style.display="none" } } }
if (window.addEventListener) window.addEventListener("load", initsidebarmenu, false) else if (window.attachEvent) window.attachEvent("onload", initsidebarmenu)
</script>
</head>
<body>
<div class="sidebarmenu"> <ul id="sidebarmenu1"> <? require_once "SimpleMenu.php"; ?> </ul> </div>
</body>
</html>
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Then, with some code from dynamicdrive.com, I created menu.php Below is the code I used:
Demo: http://houstonlively.com/menu_test/menu.php
That looks really great my friend.. Really happy with the way it turned out. You got my vote :)
Looking for Help? http://www.boonex.com/kevinmitnick |
that menu look great HL. this is fantastic .
i might use that on my site later.
one question. when i tested it on my site it dees not show up the extended sub-menu on hovering. have i done something wrong ?
thanks
mchauhan
Regards........ M.Chauhan U.K. |
I can't thank you enough for this. You've made my whole weekend.... maybe even whole year. I'll be sure to write you a stellar review. I did change these two lines:
FROM:
$sMainSubs = ($sSubMenu=='') ? '' : "
{$sSubMenu} </a>"; $this->sCode .= "<ul> <a
href='{$sLink}' {$sOnclick}
{$sTarget}>{$sPictureRep}{$sText}</a>{$sMainSubs} </ul>"; TO:
$sMainSubs = ($sSubMenu=='') ? '' : "<ul>
{$sSubMenu} </a></ul>"; $this->sCode .= "<li> <a
href='{$sLink}' {$sOnclick}
{$sTarget}>{$sPictureRep}{$sText}</a>{$sMainSubs} </li>"; Then... when you instantiate the menu, you can give the main ul an ID. All this makes the whole thing more standardized, and it worked out of the box with dynamicdrives css/javascript. Then, you can place the menu in and sub directory, and all you have to change is the path to header.inc.php
<div class="sidebarmenu"> <ul
id="sidebarmenu1"> <? require_once "SimpleMenu.php"; ?> </ul> </div>
Then, with some code from dynamicdrive.com, I created menu.php Below is the code I used:
Demo: http://houstonlively.com/menu_test/menu.php
That looks really great :) Really happy with the way it turned out
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Make sure you use the code I posted. It has two minor changes.
that menu look great HL. this is fantastic .
i might use that on my site later.
one question. when i tested it on my site it dees not show up the extended sub-menu on hovering. have i done something wrong ?
thanks
mchauhan
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Thank you HL.. You and i did some fantastic job. This will certainly help others
I can't thank you enough for this. You've made my whole weekend.... maybe even whole year. I'll be sure to write you a stellar review. I did change these two lines:
FROM:
$sMainSubs = ($sSubMenu=='') ? '' : "
{$sSubMenu} </a>"; $this->sCode .= "<ul> <a
href='{$sLink}' {$sOnclick}
{$sTarget}>{$sPictureRep}{$sText}</a>{$sMainSubs} </ul>"; TO:
$sMainSubs = ($sSubMenu=='') ? '' : "<ul>
{$sSubMenu} </a></ul>"; $this->sCode .= "<li> <a
href='{$sLink}' {$sOnclick}
{$sTarget}>{$sPictureRep}{$sText}</a>{$sMainSubs} </li>"; Then... when you instantiate the menu, you can give the main ul an ID. All this makes the whole thing more standardized, and it worked out of the box with dynamicdrives css/javascript. Then, you can place the menu in and sub directory, and all you have to change is the path to header.inc.php
<div class="sidebarmenu"> <ul
id="sidebarmenu1"> <? require_once "SimpleMenu.php"; ?> </ul> </div>
Then, with some code from dynamicdrive.com, I created menu.php Below is the code I used:
Demo: http://houstonlively.com/menu_test/menu.php
That looks really great :) Really happy with the way it turned out
Looking for Help? http://www.boonex.com/kevinmitnick |
i have used the same code as u have posted here in green colour. but for some weird reason it doesnt work on my site. i have got exactly the same files in the same directory as you. i am sending you my my site link to see if u want.
for the link please check your mailbox.
Make sure you use the code I posted. It has two minor changes.
that menu look great HL. this is fantastic .
i might use that on my site later.
one question. when i tested it on my site it dees not show up the extended sub-menu on hovering. have i done something wrong ?
thanks
mchauhan
Regards........ M.Chauhan U.K. |
HL and Kevin,
very nice job fellas, very nice indeed
Regards,
DosDawg
When a GIG is not enough --> Terabyte Dolphin Technical Support - Server Management and Support |
but the reason i came in here, to start with was to post, the menu couldnt have been "VERY HUNGRY"
Regards,
DosDawg
When a GIG is not enough --> Terabyte Dolphin Technical Support - Server Management and Support |
RE:
but the reason i came in here, to start with was to post, the menu couldnt have been "VERY HUNGRY"
Regards,
DosDawg
Nice hat ..... wish I had two like that.
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
RE:
but the reason i came in here, to start with was to post, the menu couldnt have been "VERY HUNGRY"
Regards,
DosDawg
Nice hat ..... wish I had two like that.
oh no you didnt ----> :)
When a GIG is not enough --> Terabyte Dolphin Technical Support - Server Management and Support |
Sorry HL just sent u another mail.
check that when u get time.
regards
mchauhan
Regards........ M.Chauhan U.K. |
RE:
Sorry HL just sent u another mail.
check that when u get time.
regards
mchauhan
Your demo works on my computer. Tested in IE7, FF Chrome, Opera, and Safari. PEBKAC?
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
The best part of this, is that now you can add a dolphin menu to a third party application, without having to wrap the application in a dolphin page... which can be a real headache. It opens up a lot of doors. My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
great post houston
can you post the php file for http://houstonlively.com/menu_test/menu5.php
thanks
|
looking for this great menu in a horizontal |
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Much thanks Houston
any idea on how to center menu5 in a horizontal?
also is there a trick to make the drop down list go over the other item on the page. I have a banner script under the menu and the drop down list goes behind the banner and is unclickable.
again that for your help
|
Try setting wmode="transparent" for the flash banner. My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
|
How would I know?.... it's your banner script.
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
smh
so your saying you dont know how to make the drop down list go over the other item on the page?
|
wmode is a parameter to add to flash scripts to push them to the background so it does not cover other items. So what he is saying, is, it is your banner script, so he can't tell you where it is located.
https://www.deanbassett.com |
the banner is not a flash script
the script that produces the banner and all the other content is phpMyDirectory
http://www.phpmydirectory.com/
and there is none there that i can find.
so i was asking if there is a mod/fix/code that will make the menu go on top of the page content. if not that fine ill fine another menu.
thanks all
|
OK I GOT IT FIXED
Thanks for all your help on this issue
it was as simple as adding a z-index to the menu code :)
the credit goes to mark over on the PMD board
http://www.phpmydirectory.com/community/showthread.php?p=162262#post162262
:)
|
RE:
smh
so your saying you dont know how to make the drop down list go over the other item on the page?
No.... I don't believe I said that.
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
Houston,
thank you for the great menu work. didnt mean to sound ungrateful
really appreciate it
|
OK I GOT IT FIXED
Thanks for all your help on this issue
it was as simple as adding a z-index to the menu code :)
the credit goes to mark over on the PMD board
http://www.phpmydirectory.com/community/showthread.php?p=162262#post162262
:)
CAn you please give the code here as i do not use phpm,ydirectory and want to implement the same for dolphin's main menu replacement.
Claudia
|
Morning all,
ive downloaded the stand alone file and uploaded it in a Sub dir in my olphin Root.
But the Script is not executed i just get a blank line
i Left the script as is becuase it should access the Directory just fine
<?php
require_once( '../inc/header.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php' ); require_once( BX_DIRECTORY_PATH_ROOT . "templates/tmpl_{$tmpl}/scripts/BxTemplMenu.php" );
Do i need to change any permissions on the inc Folder? or the Subfolder?
|
Okay got the directory to work but now im getting this error
Fatal error: require_once(): Failed opening required '/srv/www/vhosts/street-stars.info/httpdocs/templates/tmpl_/scripts/BxTemplFormView.php' (include_path='.:/usr/share/php5:/usr/share/php5/PEAR') in /srv/www/vhosts/street-stars.info/httpdocs/inc/utils.inc.php on line 956
Site setúp:
ROOT/MENUS/menu5.php
Iam including this in
ROOT/GALLERY/INDEX.php via a integrated interface from Coppermine
After activating i get the above error.
Any suggestions?
|
RE:
Any suggestions?
You might try overriding the default include_path in php.ini so that there is no default value
include_path = ".:"
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
I got some nice menu templates and want to add it to my dol site.
The structure of my menu :-)
-images
-index.html
-jquery.js
-menu.css
-menu.js
is there a way to add all those files to have the menu properly working within my Dolphin template?
Diddy is not greedy and has time. Dolphin is cool and its not just mine :-) |
I get 404's for HL links
Csampson |
http://ModMyCMS.com --> Dolphin Hacks &Mods |
RE
I get 404's for HL links
You should have been a detective.
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
|