How to customise Simplex menu with image

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

How to customise Simplex menu with image

Post 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!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: How to customise Simplex menu with image

Post 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.
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: How to customise Simplex menu with image

Post 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!
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

[SOLVED] How to customise Simplex menu with image

Post by jakovbak »

This topic has been solved. Tnx Velden!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: How to customise Simplex menu with image

Post 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!
jakovbak
Forum Members
Forum Members
Posts: 225
Joined: Thu Dec 13, 2012 2:54 pm

Re: How to customise Simplex menu with image

Post 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
Post Reply

Return to “The Lounge”