Menu formatting

About the template and stylesheet - and changing the menu
Post Reply
tanavots
Posts: 72
Joined: Sat Feb 25, 2012 4:18 pm

Menu formatting

Post by tanavots » Thu Dec 19, 2013 6:46 am

Is it possible format some text (or part of text) in menu differently?
E.g.
Menu 1
Menu 2
Menu 3

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

Re: Menu formatting

Post by cmb » Thu Dec 19, 2013 7:24 pm

No, that feature is not provided by CMSimple(_XH). With current CMSimple_XH versions you can, however, make a copy of function li() (in cmsimple/cms.php) and store it in cmsimple/userfuncs.php under a new name (say, formattedLi):

Code: Select all

function formattedLi($ta, $st) {
   // ...
}
Then you have to modify the call to function toc() in your template:

Code: Select all

<?php echo toc(null, null, 'formattedLi');?>
So far nothing has really changed, but now you're able to modify formattedLi() (in a way that will survive updates of CMSimple_XH). The relevant line is roughly in the middle of the function:

Code: Select all

        $t .= $h[$ta[$i]]; 
This writes the heading of the page (i.e. the content of the heading element <hX> with all further markup stripped off) to the menu. You can replace the right hand side of the .= with something else. The question is: with what -- or expressed differently: where should the marked up heading for the menu be stored? One way is to use the already (?) formatted page heading. Then simply replace the line mentioned above with:

Code: Select all

        global $c;
        preg_match('~<h([1-' . $cf['menu']['levels']. ']).*>(.*)</h~isU', $c[$ta[$i]], $temp);
        $t .= trim(xh_rmws($temp[2])); 
If you want to stick with non marked up headings on the page, but having markup in the menu, you could use the alternative heading (tab "Page").

Note, that it's also possible to set up a certain fixed markup, that is triggered by a custom page data field. You can see an example on http://www.steffens-bau.be/?Immobilien: ... %C3%A4user.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply