Giter Club home page Giter Club logo

craft-menus's Introduction

Familiar Menus

A simple but powerful menus plugin for Craft CMS build with a custom element type.

You add menus in the plugin settings and then you can add "nodes" to that menu from the "Menus" tab. A node can link to any entry in the system (including singles) or use a custom url and title

One the node is added it can be nested using the standard element sturcures interface.

NOTE: this is a very early release much more is coming

Templating

to output the nodes in you template you you call the new craft.menus.getNodes method and pass in your menu handle.

Right now thats the only template variable available but more are coming soon.

And example using bootstrap navbar syntax, but you can output using any syntax you want.


<nav>
  <ul class="nav nav-pills">

    {% nav node in craft.menus.getNodes('mainMenu') %}

      <li role="presentation"  class="
        {{ node.children|length ? 'dropdown' }}
        {{ node.active ? 'active' }}">

        <a href="{{node.link}}"
          {% if node.children|length %}
            class="dropdown-toggle" data-toggle="dropdown"
          {% endif %}>

          {{ node.title }}
        </a>

        {% ifchildren %}

          <ul class="dropdown-menu" role="menu">
            {% children %}
          </ul>

        {% endifchildren %}
      </li>

    {% endnav %}
  </ul>
</nav>

Each node has the following properties

  • node.link (relative url)
  • node.title (text of the link)
  • node.url (full url)
  • node.active (returns true if the node or a childnode matches the current url)
  • node.children (any child nodes)

Todo

  • Add variable that outputs entire menu in one tag, (based on bootstrap menu type pills, tabs and navbar)
  • Add support for locales
  • Add element action to bulk add entries to menu

craft-menus's People

Contributors

keithmancuso avatar sjadema avatar

Watchers

 avatar

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.