Idea for "open" menu

About the template and stylesheet - and changing the menu
Post Reply
Korvell
Posts: 93
Joined: Thu May 22, 2008 10:33 pm

Idea for "open" menu

Post by Korvell » Tue Sep 23, 2014 10:08 pm

I have an idea for a template layout where I need to place individual menu items in a kind of open menu - like this:
(I have inserted heading tags <H1>..<H3> to help show what I mean)

[ external image ]

All the <H1> and <H2> menu items must be visible all the time - the last <H3> line must change according to selected <H2> submenu.

Hope it makes sense...

Is this possible?

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Idea for "open" menu

Post by cmb » Tue Sep 23, 2014 10:44 pm

Korvell wrote:All the <H1> and <H2> menu items must be visible all the time - the last <H3> line must change according to selected <H2> submenu.
I suppose the simplest solution is to split the menu. Displaying the <h3> line according to the selected <h2> submenu is very simple:

Code: Select all

<?php echo toc(3, 3);?>
To have an "open" menu you can't use toc(), unfortunately, but you have to use li() with $hc. However, $hc contains all visible pages, so you have to filter out the <h3> pages. The following should work:

Code: Select all

<?php
    $temp = array();
    foreach ($hc as $i) {
        if ($l[$i] < 3) {
            $temp[] = $i;
        }
    }
?>
Finally you can display the open <h1>/<h2> menu:

Code: Select all

<?php echo $li($temp, 1);?>
The rest is CSS as usual.

Full code:

Code: Select all

<?php
    $temp = array();
    foreach ($hc as $i) {
        if ($l[$i] < 3) {
            $temp[] = $i;
        }
    }
    echo li($temp, 1), toc(3, 3);
?>
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply