I’ve been trying to create a subsidiary page, accessed by drop down menu. A file has been created in accordance with Github /getgrav/grav-theme-antimatter#dropdown-menu. The file …/user/config/themes/twentyfifteen.yaml contains:
The page exists, and can be accessed by …/main/subpage but there is no drop down menu. The screenshot for the theme implies that it supports drop down menus.
I can’t remember now but I did find it a little buggy. I think my solution was to activate another theme then reactivate the theme I was testing. Maybe it was a cache thing. I just recall it was fiddly to get the dropdown to appear, even though there was a setting for it.
But the theme in question has no such setting, so it is obviously another problem.
I’ve been using twentyfifteen for quite some time on my website and created a child theme with some modifications that enable dropdown menu.
if anyone is interested in that, drop me a note.
@pmoreno - sure, here is the relevant code for the partials/navigation.html.twig template:
{# incl. submenu, siehe https://stackoverflow.com/questions/25423375/grav-subnavigation #}
<nav id="site-navigation" class="main-navigation" role="navigation">
<div class="sidebar-nav">
<ul class="nav-menu">
{% for page in pages.children %}
{% if page.visible %}
{% set current_page = (page.active or page.activeChild) ? 'active' : '' %}
<li class="{{ current_page }} menu-item"><a href="{{ page.url }}">{{ page.menu }}</a>
{% if page.children %}
{% if page.template != "blog" %} {# blog children nicht ins menu aufnehmen ! #}
{# hier hat </button> gefehlt: #}
{% if page.children.visible.count > 0 %}<button class="dropdown-toggle"></button>{% endif %}
<ul class="sub-menu">
{% for child in page.children %}
{% if child.visible %}
<li class="menu-item"><a href="{{ child.url }}">{{ child.menu }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</nav>
you can just replace the original templte with this, or, even better, create a child theme with just this modified template.
the result will look like this:
Without doing anything else, the child theme doesn’t display anything at all other than a box, so it seems that blueprints.yaml is also needed to supply a description, name, etc. Also adding a thumbnail.jpg makes it look better.
Unfortunately, I still don’t get a drop down menu. The generated HTML is:
@counterpoint , yes, a child theme has some basic recommendations.
if it still does not work for you, you could just temporarily replace navigation.html.twig in the original theme (this is what I did before my posting) and later resore the original.
alternatively, you could try my entire child theme from here .
of course, this contains a bunch of stuff (jvascript, css, images…) that you will not want or need.
but if it works w.r. to dropdown, you can then strip everything you don’t want and only keep what is necessary for you.
ok, so I was right - I guess then, you came to grav from classicpress ?
my way to grav was from wordpress, after they went the gutenberg way, which I did not like.
at that time, I also tried classicpress, where I also saw many of your posts in the forums, so I remembered the nick and the avatar here…
classicpress seemed to be a viable alternative to wp at that time, but then I got the impression it would not gain enough momentum in terms of active core developers.
nowadays, I think I’ve been right with that assumption, I consider classicpress to be a dead horse, now.