Skip to content

Commit

Permalink
add bootstrap5 templates; add extra_class_ul variable
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Aug 5, 2021
1 parent a2d77e9 commit c60c932
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/source/templatesmod.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Nevertheless pay attention that menu template also uses two CSS classes marking
* **current_item** — marks item in the tree, corresponding to current page;
* **current_branch** — marks all ancestors of current item, and current item itself.

If needed, you can set estra CSS classes to the *ul* element with `extra_class_ul` variable. For example::

{% with extra_class_ul="flex-wrap flex-row" %}
{% sitetree_menu from "footer_3" include "trunk,topmenu" template "sitetree/menu_bootstrap5.html" %}
{% endwith %}


.. _overriding-built-in-templates:

Expand Down
2 changes: 1 addition & 1 deletion sitetree/templates/sitetree/menu_bootstrap.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load sitetree %}
<ul class="nav">
<ul class="nav {{ extra_class_ul }}">
{% for item in sitetree_items %}
<li class="{% if item.has_children %}dropdown{% endif %} {% if item.is_current or item.in_current_branch %}active{% endif %}">
<a href="{% if item.has_children %}#{% else %}{% sitetree_url for item %}{% endif %}" {% if item.has_children %}class="dropdown-toggle" data-toggle="dropdown"{% endif %}>
Expand Down
2 changes: 1 addition & 1 deletion sitetree/templates/sitetree/menu_bootstrap3.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load sitetree %}
<ul class="nav navbar-nav">
<ul class="nav navbar-nav {{ extra_class_ul }}">
{% for item in sitetree_items %}
<li class="{% if item.has_children %}dropdown{% endif %} {% if item.is_current or item.in_current_branch %}active{% endif %}">
<a href="{% if item.has_children %}#{% else %}{% sitetree_url for item %}{% endif %}" {% if item.has_children %}class="dropdown-toggle" data-toggle="dropdown"{% endif %}>
Expand Down
2 changes: 1 addition & 1 deletion sitetree/templates/sitetree/menu_bootstrap4.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load sitetree %}
<ul class="navbar-nav mr-auto">
<ul class="navbar-nav mr-auto {{ extra_class_ul }}">
{% for item in sitetree_items %}
<li class="nav-item {% if item.has_children %}dropdown{% endif %}">
<a href="{% if item.has_children %}#{% else %}{% sitetree_url for item %}{% endif %}" class="nav-link {% if item.is_current or item.in_current_branch %}active{% endif %} {% if item.has_children %}dropdown-toggle" aria-haspopup="true" id="navitem-{{ item.id }}" data-toggle="dropdown{% endif %}">
Expand Down
13 changes: 13 additions & 0 deletions sitetree/templates/sitetree/menu_bootstrap5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% load sitetree %}
<ul class="navbar-nav mr-auto {{ extra_class_ul }}">
{% for item in sitetree_items %}
<li class="nav-item {% if item.has_children %}dropdown{% endif %}">
<a href="{% if item.has_children %}#{% else %}{% sitetree_url for item %}{% endif %}" class="nav-link {% if item.is_current or item.in_current_branch %}active{% endif %} {% if item.has_children %}dropdown-toggle" aria-haspopup="true" id="navitem-{{ item.id }}" data-bs-toggle="dropdown{% endif %}">
{{ item.title_resolved }}
</a>
{% if item.has_children %}
{% sitetree_children of item for menu template "sitetree/menu_bootstrap5_dropdown.html" %}
{% endif %}
</li>
{% endfor %}
</ul>
6 changes: 6 additions & 0 deletions sitetree/templates/sitetree/menu_bootstrap5_dropdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% load sitetree %}
<div class="dropdown-menu" aria-labelledby="navitem-{{ item.id }}">
{% for item in sitetree_items %}
<a class="dropdown-item {% if item.is_current or item.in_current_branch %}active{% endif %}" href="{% sitetree_url for item %}" {% if item.hint %}title="{{ item.hint }}"{% endif %}>{{ item.title_resolved }}</a>
{% endfor %}
</div>
2 changes: 1 addition & 1 deletion sitetree/templates/sitetree/menu_foundation.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load sitetree %}
<ul class="nav-bar">
<ul class="nav-bar {{ extra_class_ul }}">
{% for item in sitetree_items %}
<li class="{% if item.is_current or item.in_current_branch %}active{% endif %} {% if item.has_children %}has-flyout{% endif %}">
<a href="{% if item.has_children %}#{% else %}{% sitetree_url for item %}{% endif %}">{{ item.title_resolved }}</a>
Expand Down

0 comments on commit c60c932

Please sign in to comment.