Giter Site home page Giter Site logo

syliusmenuplugin's Introduction

Banner of Sylius Menu plugin

Menu Plugin

Menu Plugin license Tests Status Security Status

This plugins allows you to manage your menus.

Installation

composer require monsieurbiz/sylius-menu-plugin

Change your config/bundles.php file to add the line for the plugin:

<?php

return [
    //..
    MonsieurBiz\SyliusMenuPlugin\MonsieurBizSyliusMenuPlugin::class => ['all' => true],
];

Then create the config file in config/packages/monsieurbiz_sylius_menu_plugin.yaml:

imports:
    - { resource: "@MonsieurBizSyliusMenuPlugin/Resources/config/config.yaml" }

twig:
    form_themes: ['@MonsieurBizSyliusMenuPlugin/Admin/Browser/Form/_theme.html.twig']

Finally import the routes in config/routes/monsieurbiz_sylius_menu_plugin.yaml:

monsieurbiz_menu_admin:
    resource: "@MonsieurBizSyliusMenuPlugin/Resources/config/routes/admin.yaml"
    prefix: /%sylius_admin.path_name%

Then run it:

bin/console doctrine:migrations:migrate

Customize your menu

If you want to customize your menu, like adding an image, do so by overriding the MenuItem entity (more info about overriding entities in the Sylius documentation).

Add URL Provider

The URLs selector allows you to select a URL from a list of URLs. It provides URLs for :

  • Taxons
  • Products

You can add your customer Provider by creating a class which implements the MonsieurBiz\SyliusMenuPlugin\Provider\UrlProviderInterface .interface.

Menu example

Admin form index

Admin form view

Menu front view

The front view is exactly the same as the default one.

Customize front view

A menu can look very differently depending on where it should be displayed so most of the time you will need to create your own macro for the menu items. A good place to start is the template of the main menu here: src/Resources/views/Layout/Header/_menu.html.twig where we define a macro for the menu items, and we use them directly in the template.

To get the first items of a menu you can call our custom twig function menu_first_level('main') where main is the code of the menu we want to retrieve.

Contributing

You can open an issue or a Pull Request if you want! ๐Ÿ˜˜
Thank you!

syliusmenuplugin's People

Contributors

delyriand avatar etienne-monsieurbiz avatar jacquesbh avatar lanfisis avatar mathieumaes182 avatar maximehuran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

syliusmenuplugin's Issues

Add more options instead of `url`

Hi !

Unless I'm mistaken, this plugin only allows to set a URL.
If we need one MenuItem to always point to a taxonomy, then we have to update the menu everytime we modify the slug of this taxonomy.
What would be great is to have a possibility to link to a taxonomy directly within the menu. Then either fetch the URL on render or cache it and invalidate it whenever we update the taxonomies.

What do you think ?

Improve plugin documentation

Hi,

After a few hours of research I finally found how to implement the plugin menu on the front side.

This might be useful for other developers, you have to include the _menu partial in your Twig layout like this:

{% include '@MonsieurBizSyliusMenuPlugin/Layout/Header/_menu.html.twig' %}

Is it possible to explain what the code and system fields are used for and improve the bundle documentation for the front side implementation?

Thank you :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.