Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Manage Bootstrap Dropdowns OPTIONS

Started by Muut Archive 10 years ago · 6 replies · 657 views
10 years ago

I searching for a way of easy managing the BootStrap Dropdown OPTIONS from Admin or Frontmatter

Like:

  • Divider
  • Header
  • Disable

(reference: http://www.w3schools.com/bootstrap/bootstrap_dropdowns.asp)

I'd like to find a way of using this in Frontmatter or Admin, so users can control this behaviour.
I've tried with page variables but not succesfull.

Anyone suggestions ?

I'm not a developer, so don't make it too difficult for me....

10 years ago

I don't think the bootstrap theme has these options if that is what you mean. These would have to be added to the partials/navigation.html.twig logic in the bootstrap theme.

10 years ago

That's the place where i was trying to implement this, when i put in the <li class="divider"></li> it does the work.
But i'm trying to control this from within the admin or frontmatter to let the user control this.

I've tried in Frontmatter

menuoptie:
divider:'true'

and in mij navigation.html.twig

TWIG
   {% if page.menuoptie.divider %}<li class="divider"></li>{% endif %}

But that doesn't do the job.....

Should this be possible with something like this anyway ?

10 years ago

If you add an option to the page frontmatter, you retrieve it using page.header.* not just page.*. So page.header.menuoptie.divider should get the value.

10 years ago

I've tried 'everything'... but still no luck...

I'm able to check on the {{ page.header.menuoptie.divider }} if added to the page frontmatter

But...

I think the page header will only be 'filled' when the page is active/visible
I need this variable when processing the menu for the site to create the Bootstrap divider in the navbar.

Anyone with an option / suggestion to try ?

10 years ago

Well yes, page refers to the current page.

You can use page.find('/page-route') to get any page you want.

10 years ago

Thanks for your reply, but i'm not searching for pages...

All i want to do is just 'parse' the menu.html.twig and use the {{ page.header.menuoptie.divider }} to place the bootstrap devider for the dropdown menu.

to create something like this:

If the CSS frontmatter contains
menuoptie:
divider: true

HTML
<div class="dropdown">
  <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Dropdown Example
  <span class="caret"></span></button>
  <ul class="dropdown-menu">
    <li><a href="#">HTML</a></li>
    <li><a href="#">CSS</a></li>

    {% if page.header.menuoptie.divider %}<li class=“divider”></li>{% endif %}

    <li><a href="#">JavaScript</a></li>
  </ul>
</div> 
<li class="divider"></li>

I'll hope i've explained my 'problem' clear enough now ..?!
Thanks for your patience...

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1359 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2956 9 years ago
Archive · by Muut Archive, 9 years ago
3 1121 9 years ago