Conditional sidebar display

A forum for Bolt related questions / issues

Conditional sidebar display

Postby tvchris » Mon Sep 29, 2014 12:57 pm

Loving Bolt. It's a fantastic CMS.

I've figured out pretty much everything except how to display a sidebar 'widget' (for lack of a better word) based on a checkbox or some other input on the back end.

In other CMS's I would create a radio button or select box and allow the user to turn off and on certain widgets based on the page they were editing.

I'm sure there's something I'm missing. Thank you in advance!
Posts: 1
Joined: Sun Sep 28, 2014 9:09 pm

Re: Conditional sidebar display

Postby dbrooke0830 » Wed Oct 15, 2014 3:33 am

This forum isn't exactly high traffic :-)... but I just saw that this was unanswered.. so here is my best crack at it (I'm going to assume you know a bit about BOLT / twig):

Edit your contenttypes.yml for whatever page / entry / whatever you want your checkbox in:

Code: Select all
            type: checkbox
            label: "show widget?"

then, after updating your database ('check database'), go to content => yourcontent to select/test the checkbox.

Then, for that's content's .twig file... you could do something like:

Code: Select all
    {% if mycontent.checkbox == 1 %}
      Your HTML and widget / twig code.. ie. {{ widget.title }} (after setting widget content)
    {% else %}
      Other HTML and twig code
    {% endif %}
Posts: 13
Joined: Wed Aug 06, 2014 11:07 pm

Return to Bolt Discussion

Who is online

Users browsing this forum: No registered users and 3 guests