show_menu2: valid XHTML and CSS selectable menus

succhi

#145
@brofield. I am finding my registered pages showing in my menu even with login enabled (show_menu2-3.8).

update: Woops, they are supposed to show. I forgot the difference between registered and private is that registered appears in the menu but you must be logged in to view, private you don't see in the menu at all until you are logged in.

Please forget the rest of my post unless you want registered pages to not show in your menu.

The following alterations fixed my problem so they no longer show

From this:
                if (($page['visibility'] == 'private' || $page['visibility'] == 'registered')
                    && false === strstr(",{$page['viewing_groups']},", $currGroup))
                {
                    continue;
                }


To this:
if ($page['visibility'] == 'private'
                    && false === strstr(",{$page['viewing_groups']},", $currGroup))
                {
                    continue;
                }


Stu.

learning



oops... sorry.  :oops:

Thanks for your response. I will try to nut through that and see how I go.

Cheers

*mods - Please feel free to move my previous post and reply if need be.

brofield

Try changing the class to the <a> tag. Your CSS rules then apply to a.menu-current and don't cascade to the rest. Example:
itemOpen = '<li><a class="[class]" target="[target]" href="[url]">[menu_title]</a>'

In future, note that this thread is for discussion of the SM2 output and possible bugs, like your original post. Not for CSS problems.

B

learning

Thanks for that Klaus (I feel rather silly that it was something I had missed :oops:), and yes thank you Brodie for your great work  :-D

At the risk of embarrassing myself further, I am still having troubles with the 'current menu' issue. I did as suggested earlier, and I can now get the 'current' to display properly... almost! Problem I have is, when I click on a page that has child levels, all items show as current 'in the parent form' and then to click on a child level, it restores to how it should be layed out.

For instance if this is how it should display..

Item 1
Item 2 (current)
      item 2a
      item 2b
Item 3

But it displays like this

Item 1
Item 2 (current)
Item 2a (child of current, should be small and indented)
Item 2b (child of current, should be small and indented)
Item 3

When I click on a child, it all then restores to the proper display.

I have included my css, and the html from the view source of the page.

Menu Call
<?php show_menu2(); ?>

CSS
#menu {
padding: 0;
margin: 0;
}

#menu a {
text-decoration: none;
display:block;
}

#menu ul {
padding: 0;
margin: 0;
list-style: none;
}

#menu li {
margin: 0;
padding: 0;
font-size: 11px;
font-family: Arial;
}

#menu li a {
margin-top: 8px;
padding: 0 28px;
height: 21px;
line-height: 21px;
font-weight: bold;
text-transform: uppercase;
border-top: 1px solid #AACCD5;
border-bottom: 1px solid #AACCD5;
background-image: url(li1a.gif);
background-position: 13px 5px;
background-repeat: no-repeat;
}

#menu li.menu-current a {
margin-top: 8px;
padding: 0 28px;
height: 21px;
line-height: 21px;
font-weight: bold;
text-transform: uppercase;
border-top: 1px solid #AACCD5;
border-bottom: 1px solid #AACCD5;
background-image: url(li1a-c1.gif);
background-position: 13px 5px;
background-repeat: no-repeat;
background-color: #FAF9D0;
}
#menu li li a {
margin-top: 0;
height:19px;
line-height: 19px;
font-weight:normal;
text-transform: capitalize;
background-image: url(li2.gif);
background-color: #DEECF0 ;
background-position: 13px 5px;
background-repeat: no-repeat;
border-top: 1px solid #EEF5F7;
border-bottom: 1px none #EEF5F7;
}
#menu li li.menu-current a {
margin-top: 0;
height: 19px;
line-height: 19px;
font-weight: normal;
text-transform: capitalize;
background-image: url(li2-c1.gif);
background-color: #FEF2B9;
background-position: 13px 5px;
background-repeat: no-repeat;
border-top: 1px solid #EEF5F7;
border-bottom: 1px none #EEF5F7;
}


HTML view source
<div id="menu">
<ul class="menu-top">
<li class="menu-sibling menu-first"><a href="#" target="_top">Home</a></li>
<li class="menu-expand menu-current"><a href="#" target="_top">Services</a>
<ul class="">
<li class="menu-child menu-first"><a href="#" target="_top">Pricing Guide</a></li>
<li class="menu-child menu-last"><a href="#" target="_top">Hosting Plans</a></li>
</ul></li>
<li class="menu-sibling"><a href="#" target="_top">Portfolio</a></li>
<li class="menu-expand menu-sibling"><a href="#" target="_top">About Us</a></li>
<li class="menu-sibling"><a href="#" target="_top">Contact Us</a></li>
<li class="menu-sibling"><a href="#" target="_top">Site Map</a></li>
<li class="menu-sibling menu-last"><a href="#" target="_top">Members</a></li>
</ul>


Sorry to be a pain, I am not the worlds best at coding, infact I really have no idea at all, but I will try any and all combinations before calling for help. These are just the last ones tried and the result. I have tried other call menu options too.

Thanks again.

kweitzel

Hi all, from what I know about WB, the table about the visibility settings above is correct. Therefor I added that table to the WIKI page "More on Pages". Thanks brodie for your work!

cheers

Klaus

learning


:oops: Like I said, something very simple that I was missing. Thank you.

brofield

SM2 uses the same SQL limit as show_menu() and menu(), so SM2 will have the same output as them. This sql limit eliminates private pages from the output when you are not logged in. It eliminates registered pages from the output if there is no frontend login (refer admin settings).

I guess if you are not seeing "Registered" pages when you are not logged in, then you probably don't have frontend login enabled.

B

learning


Hi There,

Yep that is what I was thinking would happen with registered pages. I just went and checked again, and it is a page set to 'registered' and it is only viewable on the menu if someone is logged in.

Cheers

brofield

#137
Update: this table now shows what SM2 is displaying. As far as I have investigated, this is the same as the output of show_menu().


Page TypeMenu VisibilityPage VisibilitySearch Results
PublicEveryoneEveryoneTrue
RegisteredEveryone *1 (or)
Logged in user in correct group *2
Logged in user in correct groupTrue
PrivateLogged in user in correct groupLogged in user in correct groupTrue
HiddenNeverEveryone, but only if they know the page URLTrue
NoneNeverEveryone, but only if they know the page URLFalse

Note:
*1 if General Settings -> Login = Enabled
*2 if General Settings -> Login = Disabled

Note: in regards to Hidden and None types, security by obscurity is no security at all. Use this for developing pages before making them live but never assume that those pages are private.

B

learning

Quote from: brofield on August 31, 2006, 07:53:29 AM
Issue 1
If you are using the default format then the menu-current class is assigned to the <li> element, not the <a> element.

Issue 2
Sure this is correct? Pages available to registered users only will appear in the menu only to registered users.

B


Thank you for your ultra fast response!!

Ok... that will give me something more to work with on Issue 1... could be my problem  :oops:

Now... with Issue 2... hmm... maybe I got it mixed up as to what it should do. If that is normal behaviour for registered pages, then maybe it is private pages I need, however I have tried both. Neither will show in the menu unless I am signed in. I want the link to be visible to all, but when the link is clicked on the person then needs to sign in before they can view the contents. Sorry if I didn't explain that very well.

Cheers

brofield

#135
Issue 1
If you are using the default format then the menu-current class is assigned to the <li> element, not the <a> element.

Issue 2
Surely this is what it should do? Pages only available to registered users will only appear in the menu if the registered user is logged in.

B

learning

I have been struggling with two issues for a few days now, and the worst part is, I am worried there are going to be a very simple solutions that I am missing. After much searching, and experimenting, I am finally posting... hopefully in the right area.

Issue 1

I had a menu structer that was working fine, however it would not function correctly in Fire Fox, so I converted to show_menu2. The menu itself, now displays and functions correctly... however one issue. The current menu css will not work. I have tried many different combinations and I just can not seem to get it to work. (again it was working fine with show_menu). I have included my css for my menu.. not sure if it will help or not.

Please not the 'current' css that I have quoted here is not all that I have tried, it is just the last one that I tried. I am sure this is something simple that I just can't figure out... sorry to be a bother. I can include the view source from my page if that helps too.

#menu {
padding: 0;
margin: 0;
}

#menu a {
text-decoration: none;
display:block;
}

#menu ul {
padding: 0;
margin: 0;
list-style: none;
}

#menu li {
margin: 0;
padding: 0;
font-size: 11px;
font-family: Arial;
}

#menu ul li a {
margin-top: 8px;
padding: 0 28px;
height: 21px;
line-height: 21px;
font-weight: bold;
text-transform: uppercase;
border-top: 1px solid #AACCD5;
border-bottom: 1px solid #AACCD5;
background-image: url(li1a.gif);
background-position: 13px 5px;
background-repeat: no-repeat;
}
#menu ul li a.menu-current{
margin-top: 8px;
padding: 0 28px;
height: 21px;
line-height: 21px;
font-weight: bold;
text-transform: uppercase;
border-top: 1px solid #AACCD5;
border-bottom: 1px solid #AACCD5;
background-image: url(li1a-c1.gif);
background-position: 13px 5px;
background-repeat: no-repeat;
background-color: #FAF9D0;
}
#menu ul li ul li a {
margin-top: 0;
height:19px;
line-height: 19px;
font-weight:normal;
text-transform: capitalize;
background-image: url(li2.gif);
background-color: #DEECF0 ;
background-position: 13px 5px;
background-repeat: no-repeat;
border-top: 1px solid #EEF5F7;
border-bottom: 1px none #EEF5F7;
}
#menu ul li ul li a.menu-current{
margin-top: 0;
height: 19px;
line-height: 19px;
font-weight: normal;
text-transform: capitalize;
background-image: url(li2-c1.gif);
background-color: #FEF2B9;
background-position: 13px 5px;
background-repeat: no-repeat;
border-top: 1px solid #EEF5F7;
border-bottom: 1px none #EEF5F7;
}


Issue 2.

I have a 'members' page... set to registered, and it wont show on the menu unless I am logged in.  From my searching I can see that only 'private' pages should have this behaviour. Is there something I am doing wrong, or is it something to do with implementing show_menu2?

Sorry again to be a pain, I just thought it was time to post before I didn't have ANY hair left!!

Cheers

Tim

#133
EDIT: I fixed it. I was still running an old version of show_menu2. (2.3.6) Cheers!

Hi Brofield,

Thanks for the reply. I must have missed that before! I do have one question though. When I implement this, it shows not only all the siblings of that page, but it shows all the pages at that level (ie pages that are children of a root page). Regardless of what page I'm on, I get a giant listing of all the pages which have a root page as a parent, even at pages which have no children.

This would be the equivalent, using your jellycan example, of always having a children/sibling menu which read "Jams, Cogs and Wheels, Large Objects, Small Objects, Procrastination, Drugs, Bold and Italics" regardless of what page you were on.

Yours however does the correct thing - when it's at a root page with no children, no menu comes up. However, I can't get mine to go away :(

Also, the

show_menu2(0, SM2_ROOT+1, SM2_CURR+1);

doesn't work for me unless I put a ' ', in there, e.g.

show_menu2(0, SM2_ROOT+1, SM2_CURR+1, ' ', [insert formatting stuff here]);

Without the spacer I just get the formatting stuff printed as text. What causes that?

Thanks for your patience.
Tim

brofield

Quote from: Tim on August 30, 2006, 07:52:14 AM
However I have one question - is there a way to make a menu such that if that page has children, its children are displayed, and if you go to one of those children, that menu changes to show that pages siblings?

You are always wanting to show the menu from the first level down, regardless of the currently selected menu. Therefore start is ROOT+1. Depth is to CURR+1.
show_menu2(0, SM2_ROOT+1, SM2_CURR+1);

See http://code.jellycan.com/sm2test/pages/enterprise.php  "Children/Siblings"
 
Quote from: Tim on August 30, 2006, 07:52:14 AM
Oh! Also. I found it useful to hack your code so that it would recognise [nbsp] as a spacer in the menu code. Saves having to use those annoying | vertical slashes to seperate menus. Just thought I'd share. ;)

Why? Just enter &nsbsp; directly into the format string. It isn't escaped by sm2.
e.g.
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, false, '&nbsp;&gt;&nbsp;<ol>', '</ol>');

B

Tim

Hi Brofield,

I'm implementing another WB installation and using your wonderful code snippet :) This particular one has two menus - a top menu and a side menu. The top menu is all the root level pages. The side menu is related to that particular "area" of the page.

However I have one question - is there a way to make a menu such that if that page has children, its children are displayed, and if you go to one of those children, that menu changes to show that pages siblings?

In effect, that once you're in that "area" of the site, the menu will stay the same regardless of whether you're on the root page or one of the children.

The more that I think about it actually this is more of a php question...

Oh! Also. I found it useful to hack your code so that it would recognise [nbsp] as a spacer in the menu code. Saves having to use those annoying | vertical slashes to seperate menus. Just thought I'd share. ;)

Cheers,
Tim

brofield

Version 3.8 now available at http://code.jellycan.com/show_menu2/


  • Generate a log error if no group 1 flag was supplied (e.g. ALL, TRIM, etc)
  • Fix bug where private pages that were not accessible by the current user were still visible in the menu (thanks to afbelow for the fix).

B

ami

Cool!
there are too many features in your module...   :roll: :-D

Keep on, its great and really flexible.
Greetings, Axel


brofield

Sorry, what I said was confusing. Because the SM2_ALL flag uses the value of 0, it is the same as if it isn't specified at all. Therefore, if you supply some flags (like SM2_PRETTY), but don't supply one of the flags like SM2_TRIM, then it will use SM2_ALL. This is different to if you don't supply the flags parameter at all. Because at that time, you get the default value, which is SM2_TRIM.

In summary, always supply all flags.

In the next version I will change it so that if you don't supply one of the required flags then it will generate an error.

B


ami

Wow, really fast answer!
So easy, I just did not see that. And I tried a lot...  :|

But whats about the default in <?php show_menu2(0, SM2_ROOT+1, SM2_START); ?>? Why does it work there as I want?

Thank you again!
Axel

brofield

You are not supplying the SM2_TRIM flag. The default is SM2_ALL. Combine it with the pretty flag with a vertical bar. i.e. SM2_TRIM|SM2_PRETTY

ami

Hi Brodie, hi all

really a great snippet. I got it to work as I want:
One vertical menu for the root, a second menu for the root+1. I took the code from your demopage:

<div class="root">
<?php show_menu2(0SM2_ROOTSM2_START); ?>
</div>
<div class="second-menu">
<?php show_menu2(0SM2_ROOT+1SM2_START); ?>
</div>


To get it correct for xhtml strict (without target=...) I changed $aItemOpen like this:
<?php show_menu2(0SM2_ROOTSM2_STARTSM2_PRETTY'[li]<a href="[url]">[menu_title]</a>'); ?>

Then there is a mistake I do not understand - what I am coding wrong?
-> On every page I see the children of all root-entries in the second menu, for every entry of root a complete UL.

The same, if I just use the flag SM_PRETTY (no other $aItemOpen). Is there something I don't see?

Only your demo like above shows the correct children of root depending to the actual page.

Thank you for this modul - may be you can identify my mistake.
Axel


brofield


Francisco

Quote from: brofield on August 24, 2006, 07:18:58 AM
See the UDM website linked from that demo for details of how to set it up. My demo page is just showing that it can be used with sm2. http://www.udm4.com/

B

Sorry for being a pain.

http://www.udm4.com/licensing/download/ - I get the .zip from there.

Now what do I need to upload/modify in the Template? If you can tell me the basic things that have to be done to get a standard UDM menu it will help me get an idea of what I need to do.

I just need the basic steps after downloading the .zip ... if you could, please tell me.

Thanks

brofield

Version 3.7 now available at http://code.jellycan.com/show_menu2/


  • Call htmlspecialchars on all strings to ensure that the output menu items are valid HTML.
  • Added new flag SM2_NOESCAPE to turn off this escaping if it isn't desired.

B

brofield

See the UDM website linked from that demo for details of how to set it up. My demo page is just showing that it can be used with sm2. http://www.udm4.com/

B