Jump to content
Sign in to follow this  
nate_02631

"Dynamenu" for osCommerce

Recommended Posts

Dynamenu is an add-in box which will display your categories as a DTHML horizontal drop-down or vertical fly-out menu, an expandable/collapsable tree menu, or even as plain vertical or horizontal menus. The main file includes easy to set options to set the type of menu you desire and the way it behaves. With Dynamenu, you can even opt not to display it in the usual "box" so that it can be seamlessly integrated with your store template for a truly custom look!

 

Dynamenu is powered by the excellent PHP Layers Menu library which has been extensively tested for cross-browser compatibility and is driven by a well-commented stylesheet to make it easy to modify. Most menus use Javascript but are rendered on-the-fly as HTML, so they fall back nicely for the poor souls without Javascript enabled.

 

Get Dynamenu for osCommerce in the contributions section here...

 

Sorry, can't post a link to a demo, but if you search Google for Dynamenu or PHP Layers Menu, it won't be hard to find...

 

Any feedback or questions are welcomed below, or just post your store link showing off your new menu!

Edited by nate_02631

** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

Great work and thanks for the contribution.

I was looking into this at some point but never got around to implement it into OSC. We use it at work for our intranet and its just great.

 

I installed this in a blink and it works as advertised ..just need to play with the settings.

 

A few questions though:

You use if (SHOW_COUNTS == 'true') {, but where is SHOW_COUNTS defined ?

Is it possible to define different icons per categories ?

is it possible to get the treeview to be expanded up to a certain depth )ie I would like the categories to show the 1srt depth of the tree expanded and leave the rest up to the user to expand as they wish

Share this post


Link to post
Share on other sites

Hi.

i have installed the contribution but the "fly out" dont work.

 

i think its because i use the STS contribution and the footer is not included in the same way. so the

 

// Output the footer for Dynamenu for osCommerce

echo $GLOBALS['dmfooter'];

tag dont get processed.

 

is there another place i can insert this tag ?

Share this post


Link to post
Share on other sites

hi

i found that for every category or subcategory there are

not nessary for me code

<img align="top" src="images/dynamenu/transparent.png" width="1" height="16" border="0" alt="" />

and

      

where i can remove it?

also - how to set 100% width for the table with menu?

Edited by dAbserver

Share this post


Link to post
Share on other sites
You use if (SHOW_COUNTS == 'true') {, but where is SHOW_COUNTS defined ?

SHOW_COUNTS is a setting in your store's configuration (not sure which panel) that tells it if you want to show the # of products in a given category in parenthesis...

Is it possible to define different icons per categories ?

Yes and no... The data structure of DynaMenu does allow a field for specific icons for categories. Trouble is in the oSC admin there's no way to specify this, so I settled on letting the user assign config for one icon. If you weren't using the category image field, you could hack DM to read that in, otherwise you'd have to do some mild hacking to allow entry of category icon when setting up cats to then be read in by DM...

is it possible to get the treeview to be expanded up to a certain depth )ie I would like the categories to show the 1srt depth of the tree expanded and leave the rest up to the user to expand as they wish

H... if you mean have root categories expanded by default, you could try adding just after line 265, which is:

if (!$level) {
  $this_expanded = '1'; // Add this line to expand all root categories

Haven't tested that, though ;-) If that's not what you meant, it's something along those lines...

i have installed the contribution but the "fly out" dont work.

Yes, this is definately because the footer is not being output... The output for the footer *must be* just before the closing </BODY> tag or you may experience alignment problems on certain browsers. I'm afraid I'm not familiar with that contribution, but if it uses HTML templates, perhaps it will parse PHP in them by placing it in the appropriate tags?

<?php  echo $GLOBALS['dmfooter']; ?>

where i can remove it?

Afraid I don't know what menu type you are referring to, but there are templates for the DHTML and plain menus, and the tree menus are driven by the library files in the lib and libjs directories, respectively...

how to set 100% width for the table with menu?

Again, don't know which menu type, but the DHTML menu table width can be controlled via the style sheet... They are well commented...


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites
Afraid I don't know what menu type you are referring to, but there are templates for the DHTML and plain menus, and the tree menus are driven by the library files in the lib and libjs directories, respectively...

 

i use menu type 1.

 

where i can remove generation of this unnecessary (for me) IMG tag FOR EVERY category or subcategory? (full remove <img blablabla />) all of them give me about 40kb code not needed for proper work. (i have more than 400 subcategories) it's not in templates, it's in laersmenu.inc.php i thought, but i can't understand where exactly?

Share this post


Link to post
Share on other sites
i use menu type 1. where i can remove generation of this unnecessary (for me) IMG tag

Gotcha... you'll find those in the dynamenu templates directory.

 

For the vertical menus, it uses the layersmenu-vertical_menu.ihtml (for the root menu) and the layersmenu-vert_sub_menu.ihtml (for submenus) templates.

 

Find and remove this line of code from those templates (or just the submenu template, if you prefer)...

<img align="top" src="{imgwww}{transparent}" width="1" height="16" border="0" alt="" />

I'm not sure what use the transparent image is used for in those menu types; it is used in tree's and plain menu for indentation purposes. Removing it does not seem to have any adverse affect, except that the menu items are tighter together (which can be compensated for in CSS)...

 

I've briefly tested on WinXP in latest Firefox, Opera & MSIE7 and it looks O.K. You may want to do further testing... But for those of you with *lots* of subcategories, that might be a good space-saving tip!


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites
SHOW_COUNTS is a setting in your store's configuration (not sure which panel) that tells it if you want to show the # of products in a given category in parenthesis...

 

Noticed this after ..dunno why it is not picked up when it works on another one, but this is not critical ;)

 

Yes and no... The data structure of DynaMenu does allow a field for specific icons for categories. Trouble is in the oSC admin there's no way to specify this, so I settled on letting the user assign config for one icon. If you weren't using the category image field, you could hack DM to read that in, otherwise you'd have to do some mild hacking to allow entry of category icon when setting up cats to then be read in by DM...

Thats exactly what I intend to do, either use the image of the cateory or add an extra "icon" field. Could you point me out as to where this settings can be used in the code or in the configuration please, wold sve me loads of time drilling through the code and the php library manual

 

H... if you mean have root categories expanded by default, you could try adding just after line 265, which is:

if (!$level) {
  $this_expanded = '1'; // Add this line to expand all root categories

Haven't tested that, though ;-) If that's not what you meant, it's something along those lines...

 

Thats exactly what I mean ..but it doesnt seems to do the trick unfortunatly :(

Share this post


Link to post
Share on other sites

Install was simple, easy, I got it up and working in no time. Killer contribution for sure!

 

One problem for me though: I was expecting to see my products showing up under my categories, as I don't have any sub-categories. How hard would it be to add a loop for products in each category to be added to the menu as well, specifically the tree menu version? Looking at the code, it is well written and documented, a clear indication that it's complicated and way over my head. If I understood what I was looking at, I'd get this thing to do it with a few cuts and pastes, but I'm lame and lack knowledge. Anyone interested in helping with this one?

 

Thanks, and again, awesome piece of work!

Share this post


Link to post
Share on other sites
Noticed this after ..dunno why it is not picked up when it works on another one, but this is not critical ;)

re: Category Counts - Not sure I follow (?) this feature appears to work as expected on all menu types...

Could you point me out as to where this settings can be used in the code or in the configuration please, wold sve me loads of time drilling through the code and the php library manual

re: using cat image for menu icon - Check out the bottom of the tep_make_cat_dmbranch function. DM builds the text-delimited-data for the PHPLM library to parse here - the required format is in the comments. You merely have to include the category image in the query up in the tep_make_cat_dmlist function, then output that info down in tep_make_cat_dmbranch...

 

(PHPLM actually does have a subclass to read directly from databases, but it required the PEAR DB lib, which I did not wan't to saddle users with)

 

Edit: In tree menus, open/closed folder icons are always used for categories which have subcategories... may have to hack the library if you want custom icons for these as well... (you're on your own there ;))

Thats exactly what I mean ..but it doesnt seems to do the trick unfortunatly :(

Hmmm.. I tried it and it seemed to work for me... adding:

$this_expanded = '1'; // Add this line to expand all root categories

just after:

if (!$level) {

...round line 265, expands the first level categories in tree menus. There does seem to be some minor wonkiness with my test setup where the first root category won't expand if on the home page or if not explicitly expanded first (which is sort of a "known" issue) which I'm trying to sort out. A shiny new penny for anyone who does!

Edited by nate_02631

** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

Maybe someone can put up a link for us see how the menu looks like.. B)

Share this post


Link to post
Share on other sites
Maybe someone can put up a link for us see how the menu looks like.. B)

Do a Google search for PHP Layers Menu - sorry can't post the link, apparently (according to mods)... You'll find all menu type examples... Though I'd like to see how some have incorporated in their stores, too!


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

I've got the menu working all fine as a horizontal menu in my head, however, how can I center it on my page? as it just aligns itself to the left and looks horrid.

Share this post


Link to post
Share on other sites
I've got the menu working all fine as a horizontal menu in my head, however, how can I center it on my page? as it just aligns itself to the left and looks horrid.

Erm.. that's just template design with HTML and CSS and is not within the scope of this thread. Maybe surround with <CENTER> tags ;-)


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

Hey Nate, any chance you know how to add the product links from each category to the menu, or is this something that's not feasible to accomplish quickly? I have the "all_products.php" add-on that loops on both categories and products, but I can't seem to figure out how to blend that stuff with this menu stuff. Any help or direction would be appreciated.

Share this post


Link to post
Share on other sites
Hey Nate, any chance you know how to add the product links from each category to the menu, or is this something that's not feasible to accomplish quickly?

I am not familiar with that module, so no I do no know. But I'm sure it's feasable; how quickly you can accomplish it I suppose depends on your PHP coding prowess...

 

If you take a look the the code in dm_categories.php, you'll see the menu is built from one simple query of the categories table (with ID/parent ID relationsips). You just need to alter that query to your liking and maybe mod the output to link to products instead of categories... Should be fairly simple for someone with at least remedial PHP knowledge... Good Luck!


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites
I am not familiar with that module, so no I do no know. But I'm sure it's feasable; how quickly you can accomplish it I suppose depends on your PHP coding prowess...

 

If you take a look the the code in dm_categories.php, you'll see the menu is built from one simple query of the categories table (with ID/parent ID relationsips). You just need to alter that query to your liking and maybe mod the output to link to products instead of categories... Should be fairly simple for someone with at least remedial PHP knowledge... Good Luck!

 

Ok, I got it working sort of (unbelievable for me, seeing as I'm more an auto mechanic than a webmaster!), but I have issues. I can't seem to get the highlighting to happen on my products (categories work fine), and I can't get the trees to expand automatically (is there a global for product ID like there is for cPath?). I will, in time, but there's one thing I need guidance with:

 

I would like to get the text of the tree compressed as much as possible to match the rest of the menu around it (single line spacing, like using <br> between them). I am not using the icons, so that's not an issue, but I don't know where to look on this one. Am I stuck this way, or can I tweak the JS stuff somewhere to change the default?

 

Mike

Share this post


Link to post
Share on other sites
Gotcha... you'll find those in the dynamenu templates directory.

 

For the vertical menus, it uses the layersmenu-vertical_menu.ihtml (for the root menu) and the layersmenu-vert_sub_menu.ihtml (for submenus) templates.

 

Find and remove this line of code from those templates (or just the submenu template, if you prefer)...

<img align="top" src="{imgwww}{transparent}" width="1" height="16" border="0" alt="" />

I'm not sure what use the transparent image is used for in those menu types; it is used in tree's and plain menu for indentation purposes. Removing it does not seem to have any adverse affect, except that the menu items are tighter together (which can be compensated for in CSS)...

 

I've briefly tested on WinXP in latest Firefox, Opera & MSIE7 and it looks O.K. You may want to do further testing... But for those of you with *lots* of subcategories, that might be a good space-saving tip!

 

Thanks!

Share this post


Link to post
Share on other sites

Right on, thanks for the tip. I'm using the tree menus, and just found the png files that set the precedent. Making smaller versions of these files seems to do the trick.

 

Another stooopid question now; How do I insert the dm_categories.php file in the middle of a string like this:

 

  $info_box_contents[] = array('text' => $home .
			$gins .
			$ghaw .
			$tech .
			$dm_string . '<br>' .
			$ghak .
			$ghac .
			$info);
 new infoBox($info_box_contents);

 

$dm_string is where I'd like the menu to appear, and the contents of all the other $xxx are simple text and links that end with <br>. I know, I'm lame, but I'm trying...

 

Thanks again for everyone's help,

Mike

Share this post


Link to post
Share on other sites
Another stooopid question now; How do I insert the dm_categories.php file in the middle of a string like this

Check out where the rendered menu is output around line 197-ish or so... You can see that the menu output is itself a string assigned to: $categories_menu... You should be able to do what you need there. If you need the menu "outside" of the scope of the DM box (for some bizarre reason), you could of course make $categories_menu GLOBAL...


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

Hey, nevermind. I simply put my menu stuff inside of the dm_categories.php file, set it to be a box, and viola.

 

Thanks again all,

Mike

Share this post


Link to post
Share on other sites
Check out where the rendered menu is output around line 197-ish or so... You can see that the menu output is itself a string assigned to: $categories_menu... You should be able to do what you need there. If you need the menu "outside" of the scope of the DM box (for some bizarre reason), you could of course make $categories_menu GLOBAL...

 

Exactly Nate ~ Thanks!

Share this post


Link to post
Share on other sites

Crap. I thought I was done needing help, but I can't for the life of me find where the menu items are set bold in any of these files. I need to override that, but can't locate where. Can someone point me to the right place?

Share this post


Link to post
Share on other sites
Crap. I thought I was done needing help, but I can't for the life of me find where the menu items are set bold in any of these files. I need to override that, but can't locate where. Can someone point me to the right place?

Erm... CSS... ;)


** Please do not PM with personal support requests (even if offering "payment"). Thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×