BentoBox

The BentoBox2 Developer Hub

Welcome to the BentoBox2 developer hub. You'll find comprehensive guides and documentation to help you start working with BentoBox2 as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Developer Documentation

Variables

The following is a comprehensive list of variables which can be exposed to a template:

account

account contains values pertinent to an account, and will be consistent regardless of the page being rendered or the theme currently in use. All of the following values are editable via the General Settings and Social pages in the BentoBox administrators panel.

  • name (string) - The name of the account.
  • logo (string) - The URL of the restaurant's logo.
  • site (json) - Settings for the restaurant's website.
    • title (string) - For use in the website's <head> tag. E.g.: <title>{{ account.site.title }}</title>c
    • meta_description (string) - For use in the website's <head> tag. E.g. <meta name="description" content="{{ account.site.meta_description }}">
    • meta_keywords (string) - For use in the website's <head> tag. E.g. <meta name="keywords" content="{{ account.site.meta_keywords }}">
    • url (string) - This website's URL.
    • domain (string) - This website's domain (i.e. the url without http://www.)
    • favicon (string) - The URL of the restaurant's favicon.
  • services (json) - Each of the external services integrated with this account. Possible values include:
    • twitter (json)
      • name (string)
      • url (string)
      • tweets (array) - The 20 most recent tweets from the linked account (excluding replies). Each tweet consist of:
        • text (string) - The content of the tweet. May contain HTML.
        • created_at (string) - The date this tweet was posted, in the ISO 8601 format. Use the date() filter to format this value for display.
    • facebook (json)
      • name (string)
      • url (string)
    • instagram (json)
      • url (string)
    • google_plus (json)
      • url (string)
    • foursquare (json)
      • id (string)
      • url (string)
    • yelp (json)
      • id (string)
      • url (string)
    • opentable (json)
      • id (string)
    • resy (json)
      • venue_id (string)
      • api_key (string)
    • seatme (json)
      • id (string)
    • google_analytics (json)
      • url (tracking_code)

current

current contains data pertinent to the specific page or box being rendered. When a box is being rendered, additional fields may be exposed.

  • name (string) - The name of the current page/box, as assigned via the Pages/Nav interface of the administrator's panel.
  • slug (string) - A unique, lower-case version of the current page/box's name with spaces replaced with hyphens.
  • url (string) - The path at which this current page/box is accessible. (E.g. /about)
  • template (string) - The path and filename to the template currently being rendered, relative to the theme's /templates/ directory.(E.g. /about.html) (not always accurate)
  • homepage (boolean) - Set to true if it this page/box is being used as the homepage of the site.
  • fields (json) - Values of the custom fields for this page/box.
  • Learn more about Custom Fields.
  • updated (string) - The date and time this page/box was last updated, in the ISO 8601 format. Use the date() filter to format this value for display.
  • created (string) - The date and time this page/box was created, in the ISO 8601 format. Use the date() filter to format this value for display.

When current is a box, the following variables will also be available:

  • categories (array) - An array of each of the categories this box belongs to. Only accessible if the box is configured to has_categories: true
  • featured (boolean) - Only accessible if the box is configured to has_featured: true
  • box_type (string) - The slug of the box's type. (i.e. the name of its config file without the file extension.) (not always accurate)
  • Additional fields will be available if this box is configured to use an engine. Learn more about Engines

theme

  • config (json) - The contents of the theme's config.json
  • options (json) - Values of the custom fields for this theme's settings, defined in on the key options in config.json.
  • Learn more about Custom Fields

navs

Navs contain Nav Items, each of which can be a page, box, or external link.

All items contain

  • name (string) - Name of the Nav Item.
  • children (array) - An array of any children Nav items.
  • type (string) - Can be link, page, or box

Items of type link also contain:

  • url (string) - As set in Pages/Nav.
  • classes (string) - Value assigned to Types in Pages/Nav.
  • internal (boolean) - Returns True if url appears relative and False if url starts with www, http, https, or //

Items of type page also contain the data which would be rendered under current if this page were being rendered. The page's name is reassigned to page_name as not to conflict with the nav item's name attribute.*

Items of type box also contain the data which would be rendered under current if this page were being rendered. The page's name is reassigned to box_name as not to conflict with the nav item's name attribute.

Active menu item example

To check if a navigation item corresponds to the page currently being rendered, compare equality on the URL attributes. E.g.{% if current.url == nav_item.url %}active{% endif %}

Use this code snippet as a starting point for your navigation code.

<nav>
{% for nav in navs.main %}
  <a href="{{ nav.url }}" {% if nav.type == 'link' %}target="_blank"{% endif %} class="{{nav.classes}}{% if nav.url == current.url or current.url in nav.children|map(attribute='url') %} active{% endif %}">
    {{ nav.name }}
  </a>
  {% if nav.children %}
    <div class="dropdown">
      {% for child in nav.children %}
      	<a href="{{ nav.url }}" {% if nav.type == 'link' %}target="_blank"{% endif %} class="{{nav.classes}}{% if nav.url == current.url %} active{% endif %}">
          {{ nav.name }}
        </a>
      {% endfor %}
    </div>
  {% endif %}
{% endfor %}
<nav>

boxes

All boxes contain the following variables:

boxes contains JSON with each of the theme's box types listed as a key. The value is json of the following form:

  • all (array) - All of the boxes with this type, displayed in the order as presented in the administrator's panel.
  • by_slug (json) - All of the boxes with this type, with each slug as a key and the full box definition as the value.
  • featured (array) - All of the boxes of this type with which have the featured checkbox checked in the administrator's panel. Only accessible if the box is configured to has_featured: true
  • not_featured (array) - All of the boxes of this type with which do not have the featured checkbox checked in the administrator's panel. Only accessible if the box is configured to has_featured: true
  • categories (array) - All of the categories which correspond to this type of box. Only accessible if the box is configured to has_categories: true
  • by_category_slug (json) - All of the categories which correspond to this type of box, with each slug as a key and the full category definition as a value. Only accessible if the box is configured to has_categories: true

If Boxes are assigned an Engine or Custom Fields then additional variables will be accessible. To view the available variables through different Engines, please see the Engines documentation.

Variables