Dynamic menu based on db value


I am running into a situation where i have to show a conditonal menu item in static pages menu plugin. I tried onRun to remove the static menu item but so far no luck.

Here is the situation.

I have a config setting where my client can enable and disable some stuff. Based on those values the menu item should be shown or removed.

What can be possible approach here?

Thanks alot in advance.

Where are the settings? If they are set in the theme settings, you can return them with the {{ this.theme }} variable and use conditional twig logic to display the menu if it’s on.

1 Like

Yes exactly.

But how i use twig to do that because i am using the static menu component from pages plugin.

Something like this

{% if this.theme.database_data == true %}
  {% component "pageMenu" %}
{% endif %}

Thanks alot. Well i meant to set or unset a value in the menu array dynamically. But already solved that.


I think it would be good if you share how you solved it. So this post can be useful as a reference.

1 Like