Page 1 of 1

How to customise Simplex menu with image

Posted: Thu Mar 31, 2016 1:08 pm
by jakovbak
Hello everyone!
I would like to customise Simplex menu with an image (logo) but it would take some Smarty or/and PHP knowledge and it's not my field.
Anyway, what I'm trying to achieve is small logo .png placed in the middle of my menu. That logo is just an image that leads nowhere, it's not a link.
So, if menu has 6 items, logo must be placed between 3rd and 4th element. Something like this:

item1 | item2 | item3 | LOGO | item4 | item5 | item6

Here is my current menu template:

Code: Select all

{strip}

{$main_id = ' id=\'main-menu\''}
{function do_class}
    {if count($classes) > 0} class='{implode(' ',$classes)}'{/if}
{/function}

{function name='Simplex_menu' depth='1'}
    {* <ul{$main_id}{if isset($ul_class) && $ul_class != ''} class="{$ul_class}"{/if}> *}
    <ul class="main-nav">
        {$main_id = ''}
        {$ul_class = ''}
        {foreach $data as $node}
            {* setup classes for the anchor and list item *}
            {$list_class = []}
            {$href_class = ['cf']}
            {$parent_indicator = ''}
            {$aria_support = ''}
    
            {if $node->current || $node->parent}
                {* this is the current page *}
                {$list_class[] = 'current'}
                {$href_class[] = 'current'}
            {/if}
    
            {if $node->children_exist}
                {$list_class[] = 'parent'}
                {$aria_support = ' aria-haspopup=\'true\''}
                {$parent_indicator = ' <i class=\'icon-arrow-left\' aria-hidden=\'true\'></i>'}
            {/if}
    
            {* build the menu item node *}
            {if $node->type == 'sectionheader'}
                {$list_class[] = 'sectionheader'}
                <li{do_class classes=$list_class}{$aria_support}><span>{$node->menutext}{$parent_indicator}</span>
                {if isset($node->children)}
                    {Simplex_menu data=$node->children depth=$depth+1}
                {/if}
                </li>
            {else if $node->type == 'separator'}
                {$list_class[] = 'separator'}
                <li{do_class classes=$list_class}'><hr class='separator'/></li>
            {else}
                {* regular item *}
                <li{do_class classes=$list_class}{$aria_support}>
                    <a{do_class classes=$href_class} href='{$node->url}'{if $node->target != ''} target='{$node->target}'{/if}>{$node->menutext}{$parent_indicator}</a>
                    {if isset($node->children)}
                        {Simplex_menu data=$node->children depth=$depth+1}
                    {/if}
                </li>
            {/if}
        {/foreach}
    </ul>
{/function}

{if isset($nodes)}
    {Simplex_menu data=$nodes depth='0' ul_class='cf'}
{/if}

{/strip}
Thank you in advance for any advice or help!

Re: How to customise Simplex menu with image

Posted: Thu Mar 31, 2016 3:02 pm
by velden
Add a line like this in your Navigator template (same position):

Code: Select all

                </li>
            {/if}

  {* add this line --> *}{if $depth == 0 && ($node@total/2==$node@iteration || ($node@total +1)/2==$node@iteration)}LOGO!{/if} 

        {/foreach}
    </ul>
{/function}
Didn't fully test it but I guess you get the point.

Re: How to customise Simplex menu with image

Posted: Fri Apr 01, 2016 7:15 am
by jakovbak
Hello Velden!
Long time no see! But nothing's changed thou... As usual, your solution is simple, fast and accurate! I followed your instructions and now my menu is exactly as I wanted.
Thank you very much once again and best regards from Zadar!

[SOLVED] How to customise Simplex menu with image

Posted: Tue May 24, 2016 7:54 am
by jakovbak
This topic has been solved. Tnx Velden!

Re: How to customise Simplex menu with image

Posted: Tue May 24, 2016 8:26 am
by velden
Good.

BTW: What about submitting some of your beautiful sites to http://welovecmsms.com/submit

And of course in the forum's 'show off' too:
http://forum.cmsmadesimple.org/viewforum.php?f=5

Think it would be nice!

Re: How to customise Simplex menu with image

Posted: Mon Jun 20, 2016 11:42 am
by jakovbak
Great remark Velden!
I will post it as soon as I'm done with it! Right now I'm working on 3 different sites but there's nothing to show because I'm still waiting for photos and texts... But I'll check some of my older work if it hasn't been posted there then I'll post it now!
Regards,
Jakov