Just a little modification

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
milkodb
Posts: 47
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Just a little modification

Post by milkodb » Tue Apr 21, 2015 3:51 am

Hi all,

I had the need to show submenu in my pages but with no "Submenu" title.
Searching here and all over the net I have not found a simple solution so I changed tplfuncs.php function <submenu()> like this:

Code: Select all

function submenu($smlb)
{
    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 ($l[$i] < $tl) {
                $tl = $l[$i];
            }
        }
        if (count($ta) != 0) {
            $level = min($cf['menu']['levels'] + 1, 6);
            
			if ($smlb == '') {
				return '<h' . $level . '>' . $tx['submenu']['heading']
				. '</h' . $level . '>'
				. li($ta, 'submenu');
				
			} elseif ($smlb == 1) {
				return '<h' . $level . '>'
				. '</h' . $level . '>'
				. li($ta, 'submenu');
				
			} else {
				return '<h' . $level . '>' . $smlb
				. '</h' . $level . '>'
				. li($ta, 'submenu');
			}            
        }
    }
}
in wich '$smlb' is a parameter passed via <?php echo submenu();?> in template.

$smlb can be empty and all goes normally, (1) and label is not shown or ('any string') that will replace the usual label.

I know it's a little something simple to do, but I think it would be comfortable if it were implemented in the next _xh versions.
I think also there are other comparable situations which could be made more easily configurable with the same system without the need to add plugins.

It's only a small consideration and I'd love to know what you think...

Thanx
Milko

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Just a little modification

Post by lck » Tue Apr 21, 2015 9:14 am

Hm, simple solution.

Option one:
add this in your template stylesheet.css

Code: Select all

.submenu h4 {
    display: none;
} 
or
Option two:
CMSimple_XH Backend:
Settings > Language > Submenu - Heading: delete entry
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

milkodb
Posts: 47
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Re: Just a little modification

Post by milkodb » Tue Apr 21, 2015 10:36 am

Thanx a lot for reply Ludwig.

Aaah, option one was so far from me ('cause genius lies in simplicity ;) ) and it's easy and functional.
While option two forces you to definitely choose whether or not to label all over the site and this is less agreeable.

But these are solutions indeed.

Thanks again.
Milko

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

Re: Just a little modification

Post by cmb » Tue Apr 21, 2015 11:21 am

Option 1 might not be optimal with regard to bots. In the HTML there is a heading (<h4> by default), but this is hidden with CSS. A search engine might fetch the heading, or might not even like that.

A classic solution is to change the value of the config option with CMSimple scripting, only when needed: http://www.cmsimple-xh.org/wiki/doku.ph ... nu_heading.

It might make sense to add this possibility to page_params, or to a new plugin. That would make it easier for the user to change the heading, and it would abstract over the particular variable, so it could be changed in the future.
Christoph M. Becker – Plugins for CMSimple_XH

milkodb
Posts: 47
Joined: Sun Jun 23, 2013 11:00 pm
Location: Italy

Re: Just a little modification

Post by milkodb » Tue Apr 21, 2015 11:39 pm

Thanx CMB,
so for now I will use the script leaving unchanged tpl file.
Milko

Post Reply