CMS Development

Levi_STA
Participant

A way to dynamically hide dnd_sections on certain Dynamic pages

SOLVE

Hi there,

I'm currently facing this issue where I'm unable to hide certain dnd_sections based on whether I'm on overview page or detail page when rendering dynamic pages via HubDB.

So for example on one page where you can see all the clickable links to go to essentially a HubDB row page when clicked, I need to hide certain sections because those are only displayed on the detail page for that certain HubDB row and it's data. Is there an easy way to do this? CSS display:none doesn't work I believe because you wrap a dnd_section in a div with a class, at least I didn't get that to work.

Any help would be much appreciated! I'm kinda lost, and have tried a lot.

Thanks

0 Upvotes
1 Accepted solution
Levi_STA
Solution
Participant

A way to dynamically hide dnd_sections on certain Dynamic pages

SOLVE

Managed to fix it by just removing all the dnd stuff and adding all into different divs and inserting the logic there.

View solution in original post

0 Upvotes
5 Replies 5
Levi_STA
Solution
Participant

A way to dynamically hide dnd_sections on certain Dynamic pages

SOLVE

Managed to fix it by just removing all the dnd stuff and adding all into different divs and inserting the logic there.

0 Upvotes
Anton
Thought Leader | Partner
Thought Leader | Partner

A way to dynamically hide dnd_sections on certain Dynamic pages

SOLVE

Hi @Levi_STA

you could 

- add a boolean(checkbox) like "Show section X" as a column to your table and wrap the corresponding section in an if statement like

{% set table_info = hubdb_table_rows( "Your-HubDB-ID" ) %} 

{% for row in table_info %}
{% if row.show_section_x %}
...
Your layout
...
{% endif %}
{% endfor %}

 

- you could "automate it" by showing your layout based on an input from a different column. So if you'd like to show a specific section if the content(text) of a different column is "Cars" you could do it like this

{% set table_info = hubdb_table_rows( "Your-HubDB-ID" ) %} 

{% for row in table_info %}
{% if row.headline == "Cars" %}
...
Your layout if the headline is cars
...
{% elif row.headline == "Bikes" %}
...
Your layout if the headline is bikes
...
{% elif row.headline == "" %}
...
Your layout if the headline is empty
...
{% else %}
...
Fallback for everything else
...
{% endif %}
{% endfor %}

 

 

best, 

Anton

 

p.s: Those  techniques require a custom pagetemplate with all of your HubDB settings/layout/functions and the parent & child page layouts.

 

 

Anton Bujanowski Signature
0 Upvotes
Levi_STA
Participant

A way to dynamically hide dnd_sections on certain Dynamic pages

SOLVE

But the problem with that is we can't have logic inside a dnd_area. So to show a section we would have to put that if in a dnd_area which doesn't work. And we can't have multiple sections based on an if, as that also didn't give results.

0 Upvotes
Anton
Thought Leader | Partner
Thought Leader | Partner

A way to dynamically hide dnd_sections on certain Dynamic pages

SOLVE

That's correct but you can wrap the whole dnd_area inside the if-statement like this:

{% set table_info = hubdb_table_rows( module.hubdbtable_field ) %} 

   {% block body %}
        {% for row in table_info %}
            {% if row.show_section %}
                {% dnd_area 'section a' %}
                    <h1>
	                    {{ row.headline }}
                    </h1>
                {% end_dnd_area %}
            {% else %}
                {% include_dnd_partial path='path/to/saved/section' %}
            {% endif %}
        {% endfor %}


    {% dnd_area 'something else' %}
    {% end_dnd_area %}
    {% endblock body %}

 

best, 

Anton

Anton Bujanowski Signature
0 Upvotes
Levi_STA
Participant

A way to dynamically hide dnd_sections on certain Dynamic pages

SOLVE

I understand, but that dnd_area is in a dnd_section. So we can't have logic in there either. And you can't have 2 dnd_sections, at least not from what I've seen.

0 Upvotes