Author Topic: show_menu2: valid XHTML and CSS selectable menus  (Read 198921 times)

Offline rabsaul

  • Posts: 271
    • http://www.pactumgroup.com
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #25 on: February 28, 2006, 05:47:17 PM »
Hello,

this snippet seems what you need. Looked at the link you posted above. You have a horizontal menu wich should only show the root level. This you got in your template with <?php show_menu2(1, SM2_ROOT, SM2_START); ?>. And the menu on your right side wich shows all pages you got with <?php show_menu2(); ?>.

The Layout you define in the screen.css. Your existing one should work without changes. (not shure, done only a short look on it)

Matthias
Thanks, Matthias... the thing is that this is hard-coded, and I want *only* those particular links you see there, not every page that gets created at the root level. Make sense? Will this still work somehow?

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8413
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #26 on: February 28, 2006, 06:07:57 PM »
Hello,

There is a ability to only show menus using the page_id, but I'm not shure if it's possible to define more then one page_id. Please ask brofield.

Matthias

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #27 on: March 01, 2006, 03:33:51 AM »
Is there a way I can work with this code snippet to provide an "on state" for links I'm "hard-coding" into the template?

If I understand you correctly:
  • you have a fixed set of menu items that you want displayed in the top menu bar
  • you want to highlight the current page in that menu but can't at moment as using hardcoding
  • you don't want to display all top level menu items as it may change

As ruebenwurzel suggested, use a fixed parent for the menu.
  • Create a menu item and set it to invisible, this is the parent. See the admin URL for the page ID of this page, you will use it later.
  • Create the menu items in it for the top of the page below it. Use the MenuLink type. These children are visible.

This menu won't show normally because of the invisible parent. However, you can show it in your template where-ever you want by specifying the ID of the invisible parent:
<?php show_menu2(1, **INVISIBLE_PAGE_ID**, SM2_ALL, SM2_ALL); ?>

Style it using CSS:
.menu-current { font-weight: bold; }

The menu "Hidden Menu" at the demo site (see main post for URL) uses this technique.

Cheers,
Brodie

Offline rabsaul

  • Posts: 271
    • http://www.pactumgroup.com
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #28 on: March 01, 2006, 04:10:02 AM »
Thanks, Brodie.

Oops, I should have come back to this thread and mentioned that I had got another solution:

http://forum.WebsiteBaker.org/index.php/topic,2652.0.html

As you'll see from the above, the only problem I'm having is the home page. I haven't figured out the PageName call for it, since it's being "redirected." I've tried, welcome, index, default, home, default_page, default_link etc. No luck yet.

tim

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #29 on: March 01, 2006, 08:14:24 AM »
when you mean homepage, do you actually mean the intro page? Then you would find it is named "intro.php".

Otherwise the first page in your structure of created pages (normally the hompage) has pageid 0. But I think you mean the intropage. This is a static page and not in the DB.

cheers

Klaus

Offline rabsaul

  • Posts: 271
    • http://www.pactumgroup.com
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #30 on: March 01, 2006, 08:21:42 AM »
No, it is not a static page. My home page is simply the top page in the site structure. It is dynamic like all the rest.

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #31 on: March 01, 2006, 08:23:30 AM »
Keep this discussion on topic. Move yours to
http://forum.WebsiteBaker.org/index.php/topic,2652.0.html

Regards,
Brodie

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #32 on: March 01, 2006, 09:16:48 AM »
sorry for that, replied to the other post ...

cheers

Klaus

Stu-Art

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #33 on: March 01, 2006, 10:05:39 AM »
Hi, the css menu do not work on your example page in IE 6 (http://riseup.co.nz/pages/index.php).  However you say on this page you lifted the code from the pure css menus example, which DOES work on my IE 6 and IE 7 browser. I think they apply a little js script for compliance.

Have a look here http://dean.edwards.name/IE7/compatibility/Pure%20CSS%20Menus.html

Can this be added to your improved menu code?

Stu...



brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #34 on: March 01, 2006, 10:26:19 AM »
It's a demo page for the menu generation function, not for the menu itself. The HTML is correct, it is just browser's (IE6 in particular, but also FF 1.0x and others) which can't handle it. Sure there are work arounds to make it look better in different browsers, but it doesn't really matter for a demo. In any case, I did install IE7 for the hell of it.

Cheers,
Brodie

BTW, calling Dean Edwards IE7 a "little js script" is understating it just a little, no? :-)

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #35 on: March 03, 2006, 03:46:13 AM »
Updated to version 2.6

* bug fix for 2.5, drop in replacement
* fixed bug where multiple page menus were not working correctly. Now defaults the menu to 0 which will use the default menu for that page (as far as I can see). Passing 1 for $aMenu will continue to get the main menu.
* added more items to the template so that now you can customize the generated item more
* a little faster
* doesn't output the menu-N and menu-child-N classes by default. Optionally turn it on.

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8413
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #36 on: March 03, 2006, 11:44:36 PM »
Hello,

tried your latest version (2.6) on different installations and got always the following error:

Code: [Select]
Warning: array_keys() [function.array-keys]: The first argument should be an array in C:\Intranet\Apache2\htdocs\modules\show_menu2\include.php on line 123

Warning: Invalid argument supplied for foreach() in C:\Intranet\Apache2\htdocs\modules\show_menu2\include.php on line 123

Until 2.5 all works very fine. You change the $aMenu, so i tried it with '0' and '1' and also tried without any arguments, always the same result. Whats going wrong?

Thanks for this great code snippet and for your help

Matthias

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #37 on: March 06, 2006, 01:36:30 AM »
Must've screwed something up. It works fine on my test installation, so if you can figure out what the menu structure is that causes the error then I would appreciate it. I won't get to it for a few days at least though as I am not where my computer is. In meantime I will downgrade the release.

Cheers,
Brodie

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8413
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #38 on: March 06, 2006, 06:24:34 AM »
Hello,

So here a short description, hope its enough:

Have a page with only rootpages (now subpages) = Error on every page
Have a page with rootpages and subpages = Error only on pages without subpages

Matthias

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #39 on: March 07, 2006, 01:13:49 PM »
I don't see how this is different from http://riseup.co.nz/pages/flidget.php
It has no subpages, yet there is no error from it.

I changed the way show_menu2 determines the parent items of the current page from doing it manually to using the page_trail data that WB stores. This appears to be what is causing the problem. It appears that the page_trail data stored for your pages is not correct.

How old is your WB installation? How many times has it been updated? Do you understand the WB database enough to check the page_trail data and see if it is stored correctly? If there is a chance that some WB databases don't correctly store this info then I will change back to the old way.

Brodie

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8413
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #40 on: March 07, 2006, 02:56:52 PM »
Hello,

this is a new clean WB 2.6.2 installation and your script works perfectly till version 2.5.

Quote
I don't see how this is different from http://riseup.co.nz/pages/flidget.php
It has no subpages, yet there is no error from it.

The different is your complete Site structure has subpages. My problems are only with homepages wich have in the complete site structure no subpages. Hope this is more understandable.

Try a new clean WB installation and make only a few pages with no subpages and then try your show_menu2.

Looked at the page_trail database. So it seems that subpages have two entries (the root and the subpage) and root pages only have one entry. Could it be that your script needs a second entry on one page otherwise it produces an error? Thanks for your help. 

Matthias
« Last Edit: March 07, 2006, 05:13:37 PM by ruebenwurzel »

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #41 on: March 09, 2006, 08:09:50 AM »
Ok. I found the problem you were running into. It was only NOTIFY errors that were being produced, so the original version should have still worked, just noisily. I put up a new version of 2.6 which should solve the problem.

Cheers,
Brodie

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8413
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #42 on: March 09, 2006, 08:42:46 AM »
Hello,

Thank you for this fantastic snippet. Version 2.6 works like a charm, i love it.

Matthias

Tim

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #43 on: March 10, 2006, 07:58:18 AM »
Hi Brofield,

I've implemented this snipped like you suggested in the other thread and it's working like a charm - however I have run into one small issue.

If you look at http://timtekindustries.com/wb you can see that the children (under Home) are formatted (using divs) so that they have a white left border, are indented and are in normal weighted text.

However if you click on one of those children the code that this snipped generates means that they are no longer classed as children for some reason and so they lose this formatting. However ideally I'd like for them to always maintain this bordered/indented formatting regardless of whether they are the current page or not - they're still children of the parent, but for some reason the code that show_menu2 outputs doesn't give them a child class.

Is there any way to get around this? I'm calling show_menu2() with no parameters, btw.

Thanks,
Tim
« Last Edit: March 10, 2006, 08:01:14 AM by Tim »

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #44 on: March 10, 2006, 08:12:48 AM »
What you are wanting to do is format the menu depending on if it has children or not (independent of what the current page is). The menu-child class indicates that the item is a child of the current page. You want to use the menu-expand class instead, which indicates that it has children. The trouble is, by using divs for both menus and menu items, it is hard to style it correctly. Add a custom class to either a menu or an item so that you can determine which one it is, or better go back to using UL/LI.

Something like...

div.menu-top { /* top level formatting */ }
div.menu-expand > div.item { /* indent formatting */ }

Menu's really fit the UL/LI structure best.

ul.menu-top { /* top level formatting */ }
ul.menu-top ul { /* sub level formatting */ }

PeterM

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #45 on: March 10, 2006, 08:38:59 AM »
Would it be possible to incorporate this script into the standard WB zip-file. I didn't use this snippet to make the menus of my templates, because of the fact that it's not standard WB yet.

Some of my templates, for instance, K2 would have looked better with this template.

Stefan

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #46 on: March 10, 2006, 09:25:57 AM »
@PeterM
Definitely. I guess it could be a drop-in replacement for the current core menu (frontend::menu())

@brofield
Can you modify the wrapper functions page_menu() and show_menu() to utilize your script but keep the current order of parameters (for backwards compatibility) ?

Offline bupaje

  • Posts: 592
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #47 on: March 11, 2006, 09:40:58 AM »
Thanks! Decided to try this on my site and it works fantastic!

A minor CSS question ... I used this

.menu-child{
   background-color: #F3F3F3;
   border : 1px solid #EEEEEE;
}

.menu-current{
   background-color: #DDDDDD;
   border : 1px solid #16B144;
}
 

.menu-expand{
                font-weight: bold;
}


and you can see if you go here http://stormvisions.com/pages/art-design/3dgamestudio.php that the second level pages with no subpages are bold instead of only the pages with subs. Any hints?

Three thumbs up!

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #48 on: March 11, 2006, 09:53:10 AM »
font-weight is inherited by the child menus. Try
.menu-expand > a { font-weight: bold; }

This will only modify the <a> links directly underneath a .menu-expand classed tag and no children.

B

brofield

  • Guest
Re: show_menu2: valid XHTML and CSS selectable menus
« Reply #49 on: March 11, 2006, 10:19:39 AM »
@brofield
Can you modify the wrapper functions page_menu() and
show_menu() to utilize your script but keep the current order
of parameters (for backwards compatibility) ?

It is actually quite difficult due to the item formatting that show_menu uses. There are a few problems:

  • the default item class. There is no such thing as a default item class that is used for every item EXCEPT FOR THE CURRENT ONE in show_menu2. This means that I can't generate exactly the same menus that show_menu currently is.
  • the [class] replacement string. The class is automatically added to the last tag in the item open tag. This is different to the item format string.
  • the item format string is combined with the open tag. In show_menu2 these are separated. I can probably rewrite it to be combined, but then it may not be possible to put the classes exactly where you want to.

Have done a first kick at changing sm2 such that a merge of show_menu and show_menu2 will be possible. It is running at the demo site now (see the README file there). Will continue to play a little to see what I can do.

B
« Last Edit: March 11, 2006, 10:21:20 AM by brofield »