Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 06:48:26 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
149621 Posts in 21098 Topics by 7537 Members
Latest Member: lotte2
* Home Help Search Login Register
Pages: 1 ... 4 5 [6] 7 8 ... 13   Go Down
Print
Author Topic: show_menu2: valid XHTML and CSS selectable menus  (Read 99367 times)
brofield

Offline Offline

Posts: 224


WWW
« Reply #125 on: August 27, 2006, 10:28:53 AM »

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
Logged
ami

Offline Offline

Posts: 27


« Reply #126 on: August 27, 2006, 10:37:20 AM »

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

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
Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #127 on: August 27, 2006, 10:44:45 AM »

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

Logged
ami

Offline Offline

Posts: 27


« Reply #128 on: August 27, 2006, 10:48:01 AM »

Cool!
there are too many features in your module...   rolleyes grin

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

Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #129 on: August 27, 2006, 11:50:48 AM »

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
Logged
Tim

Offline Offline

Posts: 7


« Reply #130 on: August 30, 2006, 06:52:14 AM »

Hi Brofield,

I'm implementing another WB installation and using your wonderful code snippet Smiley 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. Wink

Cheers,
Tim
Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #131 on: August 30, 2006, 07:14:20 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"
 
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. Wink

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
Logged
Tim

Offline Offline

Posts: 7


« Reply #132 on: August 31, 2006, 04:09:50 AM »

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 Sad

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
« Last Edit: August 31, 2006, 04:19:00 AM by Tim » Logged
learning

Offline Offline

Posts: 61


« Reply #133 on: August 31, 2006, 06:49:52 AM »

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.

Code:
#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
Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #134 on: August 31, 2006, 06: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
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
« Last Edit: August 31, 2006, 07:08:47 AM by brofield » Logged
learning

Offline Offline

Posts: 61


« Reply #135 on: August 31, 2006, 07:08:11 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  embarassed

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
Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #136 on: August 31, 2006, 07:26:40 AM »

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
« Last Edit: September 08, 2006, 11:18:39 AM by brofield » Logged
learning

Offline Offline

Posts: 61


« Reply #137 on: August 31, 2006, 07:31:12 AM »


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
Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #138 on: August 31, 2006, 08:06:35 AM »

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
Logged
learning

Offline Offline

Posts: 61


« Reply #139 on: August 31, 2006, 08:25:39 AM »


 embarassed Like I said, something very simple that I was missing. Thank you.
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6819


WWW
« Reply #140 on: August 31, 2006, 08:56:53 AM »

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
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

learning

Offline Offline

Posts: 61


« Reply #141 on: September 01, 2006, 12:40:25 AM »

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

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
Code:
<?php show_menu2(); ?>

CSS
Code:
#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
Code:
<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.
Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #142 on: September 01, 2006, 01:14:33 AM »

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
Logged
learning

Offline Offline

Posts: 61


« Reply #143 on: September 01, 2006, 01:34:35 AM »



oops... sorry.  embarassed

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.
Logged
succhi

Offline Offline

Posts: 72


« Reply #144 on: September 27, 2006, 02:00:25 PM »

@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:
Code:
                if (($page['visibility'] == 'private' || $page['visibility'] == 'registered')
                    && false === strstr(",{$page['viewing_groups']},", $currGroup))
                {
                    continue;
                }

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

Stu.
« Last Edit: September 28, 2006, 08:10:32 AM by succhi » Logged
yppds

Offline Offline

Posts: 32


« Reply #145 on: October 25, 2006, 09:31:36 AM »

Hi!,

I know that the issue of show_menu2 has been extensively discussed in the forum, but I’m pretty desperate and need your help, after 5 hours of searching.

It is a multilingual site that has the following tree structure:

en
->home page
->News
->->news1
->->news2
->Pictures
->->Pictures 1
->->Pictures 2
de
->startseite
->Neues
->->neues1
->->neuses2
->Bilder
->->Bilder1
->->Bilder2

This site uses both show_menu2 and udm.

When the user is on the English page he will see only the English menu. When in deutch, he will see the deutch menu. To make it multilingual, I have followed – successfully - the tutorial that is posted on the wiki of WebsiteBaker and I have used the following to display the menu: show_menu2(0, SM2_ROOT+1, SM2_ALL, SM2_TRIM, false, false, ‘<ul class=”udm” id=”udm”>’);

Everything works fine. The problem starts when you click for instance on the Pictures1 link of the menu. The Pictures menu is becoming activated, but the News menu is becoming deactivated (it is shown, but you have to click on it, to show you the children of the menu). Also, assuming you click on News1, then the Pictures menu is becoming deactivated and you can only see the children if you click on it.

All I want is to make the menus always visible and activated, nomatter which route the user chooses.

Any help would really be appreciated.
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6819


WWW
« Reply #146 on: October 25, 2006, 02:54:17 PM »

Haven't used that menu style myself, but from my understanding this is how it is supposed to work, actually ...

You can look for the breadcrumbs function to give you that page trail you would like to see (or as well the show_menu2 function).

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

yppds

Offline Offline

Posts: 32


« Reply #147 on: October 25, 2006, 03:13:05 PM »

Hi Klaus

Thanks for you help!

Well, after many trial and errors, I figure out one simple thing that might help you to guide me.

All I want is to make the menu always stay expandable. I don't want it to collapse.

The problem starts when you move from one category to the other. When you choose the Pictures category, it hides the News category (and all children) and shows only the contents of the Pictures menu category.

Could it be that the problem I have relates more with PHP code in include.php or legacy.php , than with how you type the show_menu2 function?

Looking forward for your help.
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6819


WWW
« Reply #148 on: October 25, 2006, 04:31:07 PM »

you might be right three ... why don't you have a look at the source view of some redered pages ... then you will see if it is or not ... in general the menu function "resets" on every page loaded.

But also, these kind of menus are usually designed, that they do exactly that ... maybe it is not the right menu for you ... have you looked for explanations about the UDM Menu?

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

brofield

Offline Offline

Posts: 224


WWW
« Reply #149 on: October 25, 2006, 06:50:50 PM »

Seems to me that you want to use SM2_ALL instead of SM2_TRIM. Not sure that UDM is what you want either, since UDM is about create popup menus and you want to show the entire site structure all of the time.
Logged
Pages: 1 ... 4 5 [6] 7 8 ... 13   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!