contributte / menu-control

🍔 Menu and breadcrumb components for Nette framework (@nette)
MIT License
28 stars 20 forks source link

How can I use Icons in menu ? #7

Closed mhascak closed 10 years ago

mhascak commented 10 years ago

Hello, I have one question. Is possible to use Icon in menu ? I see that you add method setIcon()... How can I specify icon in neon syntax ? Thanks for help and for this component!

davidkudera commented 10 years ago

This method is just shortcut to getData('icon'). Also you will have to use custom template. Small example with font awesome icons:

neon:

menu:
    default:
        template:
            menu: %appDir%/components/Menu/menu.latte

    items:
        Homepage:
            target: Homepage:default
            data:
                icon: fa fa-home

template:

<ul>
    <li n:foreach="$menu->getItems() as $item">
        <a href="{$item->getLink()|noescape">
            <i class="{$item->getIcon()}"></i> {$item->getTitle()}
        </a>
    </li>
</ul>

Do not forget to check if displayed item is allowed, see built in template.

Edit: *Data methods are just for transferring any data you may want from neon configuration to latte templates.

mhascak commented 10 years ago

Thnaks for help ! Works :)

davidkudera commented 10 years ago

Glad to help ;-)