WebsiteBaker Support (2.8.x) > Templates, Menus & Design

show_menu2: valid XHTML and CSS selectable menus

<< < (20/64) > >>

brofield:
Re-released the final beta as version 3.0

Question:
Show show_menu2 be calling htmlspecialchars() on the page title, menu title, description, etc. The original show_menu doesn't, but it seems to me that it puts too much responsibility on the user to know that they need to write &amp; instead of a single &. Plus if they put angle brackets in their text it will possible screw up the output.

Does anyone use this "feature"? I think that I should be calling at least htmlspecialchars. See the demo site at http://code.jellycan.com/sm2test/ for an example. The page is called "<b>Bold</b> & <i>Italics</i>".

Brodie

melissa:
Wow guys. I am so impressed.

This is the first time I've had a chance to come back to show_menu2 to see if I can use it with UDM, and I see you even have a demo of using UDM to make it really easy for me!

succhi and brofield, thanks for your hard work on this code.

Here's one more demo -


--- Code: ---show_menu2(3, SM2_ROOT, SM2_START, SM2_ALL,
'&nbsp;|&nbsp;<span><a href="[url]">[menu_title]</a></span>',
'',
'',
'',
'<span><a href="[url]">[menu_title]</a></span>',
'');
--- End code ---

I'm using it for a menu at the bottom of the page (using multiple menus), and it comes up like this:

Privacy Policy | Terms & Conditions | Contact Us

Melissa.

succhi:
@brofield

Mate I am trying to work out why the menu doesn't show when I am on a page with a PAGE_ID of 0. The search page is just such a page and the menu goes 'bye-bye'.

Any quick ideas?

Update:
I found part of the problem.
When the page_id = 0 $wb->page['menu'] is empty.


--- Code: ---// fix up the menu number to default to the menu number
// of the current page if no menu has been supplied
if ($aMenu == 0) {
    $aMenu = $wb->page['menu'] == '' ? 1 : $wb->page['menu'];
}
--- End code ---

That fixes part of it. However I now have a menu that is fully expanded. I need to fix this part now.

Update 2:
I have found where it starts to go funny but I am not sure what the best fix would be.


--- Code: ---sm2_mark_children($rgParent, PAGE_ID, 1);
--- End code ---

If PAGE_ID != 0 then it is fine, it marks things correctly however with PAGE_ID == 0 every single item gets marked so the entire menu gets expanded when recursed. What do you think the best fix is Brodie?

Update 3:
OK if I do the following I get the result I am after.

--- Code: ---// mark all children of the current page
if (PAGE_ID != 0) {
   sm2_mark_children($rgParent, PAGE_ID, 1);
}

--- End code ---
I know that search should have no children so lets not even go down the track of marking anything. That's fixed it for me, plus I set all the $wb->page[] settings that might not be set due to PAGE_ID == 0.

@Brofield. Let me know if you can think of a better way to fix these problems. It took me near two hours + to work out what all the different levels of arrays you've got going on were doing. doing print_r($array) stuff everywhere to visualise what was happening.

Stu.

brofield:
@succhi
Thanks for the debugging work. It can be a real a b**** to work on someone else's code. Your solution seems fine to me. It sounds like there are more changes than what you have in this post, did you want to email the changed files to me? I'll roll it up and release it.

B

brofield:
New version available at http://code.jellycan.com/show_menu2/

* Fixes for menu display on special pages (e.g. search results page) as provided by succhi
* New flag SM2_NOCACHE to force a new read from the database

B

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version