Funkcion submenu

Please post the URLs to pages, where you've made a CMSimple template available for download

Moderator: mikey

Post Reply
oldnema
Posts: 265
Joined: Wed Jan 21, 2009 5:15 pm
Location: Czech Republic
Contact:

Funkcion submenu

Post by oldnema » Wed Jun 08, 2016 7:23 am

Hello all, I need some advice. It is possible to adjust <?php echo submenu() ?> to display links as well as the function <?php echo toc(2,3);?>, ie so that all links are still visible?
Thank you for your ideas.
Josef
Nobody knows how much time he has left ...
http://oldnema.compsys.cz/en/?Demo_templates

cmb
Posts: 12778
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Funkcion submenu

Post by cmb » Wed Jun 08, 2016 9:26 am

Hi Josef!

I assume you want to have the submenu show all subpages including the subpages of the subpages; basically, a toc(x,3), where x is the menulevel of the first child of the current page. In other words, a nested submenu. That would be easy. Just use the following function (this is a modified submenu() of CMSimple_XH 1.6.7):

Code: Select all

function nested_submenu()
{
    global $s, $cl, $l, $tx, $cf;

    $ta = array();
    if ($s > -1) {
        $tl = $l[$s] + 1 + $cf['menu']['levelcatch'];
        for ($i = $s + 1; $i < $cl; $i++) {
            if ($l[$i] <= $l[$s]) {
                break;
            }
            if ($l[$i] <= $tl) {
                if (!hide($i)) {
                    $ta[] = $i;
                }
            }
        }
        if (count($ta) != 0) {
            $level = min($cf['menu']['levels'] + 1, 6);
            return '<h' . $level . '>' . $tx['submenu']['heading']
                . '</h' . $level . '>'
                . li($ta, $l[$s] + 1);
        }
    }
}
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

oldnema
Posts: 265
Joined: Wed Jan 21, 2009 5:15 pm
Location: Czech Republic
Contact:

Re: Funkcion submenu

Post by oldnema » Wed Jun 08, 2016 9:40 am

Thank you for the quick response, just do not know to which group I'm yours embed code. :oops:
Nobody knows how much time he has left ...
http://oldnema.compsys.cz/en/?Demo_templates

cmb
Posts: 12778
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Funkcion submenu

Post by cmb » Wed Jun 08, 2016 11:06 am

oldnema wrote:[…], just do not know to which group I'm yours embed code.
You can put the code in template.htm (at the top), enclosed in <?php ... ?> like so:

Code: Select all

<?php
function nested_submenu()
{
// rest of code as above
}
?>
Then replace the submenu() call in the template with nested_submenu().
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

Post Reply