Expandible submenu()

Questions about how to install and problems installing - please read the documentation first!
Post Reply
Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Expandible submenu()

Post by Tata » Sat Jun 21, 2014 8:24 pm

Is there a way to have the submenu() expandible? It would save a lot of page space (especially if the page has only a little text but many subpages).
There are many "pure CSS" solutions. But they require too much inline styling. I think anout something that would make it optional showing the menu collapsed or expanded. E.g. depending on number of subpages (e.g. having more than 5 subpages, show the submenu automatically collapsed).
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Expandible submenu()

Post by Tata » Sun Jun 22, 2014 5:32 am

A little dirty (but working) solution:
In core.css new selectors

Code: Select all

/* submenu*/
	#submenu, 
	.show, 
	.hide:focus {display: none; }
    .hide:focus + .show, 
    .hide:focus ~ #submenu {display: inline; }
    @media print { 
    	.hide, .show { display: none; } 
    	}
In tplfuncs.php find (#633)

Code: Select all

        if (count($ta) != 0) {
            return '<h4>' . $tx['submenu']['heading'] . '</h4>'
                . li($ta, 'submenu');
and replace by

Code: Select all

        if (count($ta) != 0) {
            /*return '<h4>' . $tx['submenu']['heading'] . '</h4>'.*/
            return '
                <a href="#" class="hide"><h4>' . $tx['submenu']['heading'] . '(+)</h4></a>
                <a href="#" class="show"><h4>' . $tx['submenu']['heading'] . '(-)</h4></a>
                <div id="submenu">'.
                    li($ta, 'submenu').
                '</div>';
The (+/-) may of course be placed before the "$tx['submenu']['heading']" and/or replaced by an image or styled howsoever in a <span> in core.css.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

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

Re: Expandible submenu()

Post by cmb » Sun Jun 22, 2014 12:27 pm

Tata wrote:A little dirty (but working) solution:
Um, didn't work for me.

However, why not simply:

Code: Select all

.submenu ul {display:none}
.submenu:hover ul {display:block}
/* h4 has to be changed if menu_levels != 3 */
.submenu h4:after {content: "(+)"}
No further modifications seem to be necessary.
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Expandible submenu()

Post by Tata » Sun Jun 22, 2014 12:35 pm

Now I see, that the links do not work for me either. The submenu expands, but links are out of function. Why about?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Expandible submenu()

Post by Tata » Sun Jun 22, 2014 12:55 pm

Ja, das funktioniert.
Es brauchte nur

Code: Select all

        if (count($ta) != 0) {
            return '<div class="submenu"><h4>' . $tx['submenu']['heading'] . '</h4>'
                . li($ta, 'submenu').'</div>';
und

Code: Select all

/* SUBMENU */
.submenu{ margin-top: 1rem;}
.submenu ul {display:none;}
.submenu:hover ul {display:block;}
/* h4 has to be changed if menu_levels != 3 */
.submenu h4:after {content: "(+)"}
Noch immer testweise am http://zomos.cmsimple.sk
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply