CMS Development

InciteJoe
Mitwirkender/Mitwirkende | Gold Partner
Mitwirkender/Mitwirkende | Gold Partner

Conditional Statement on Blog Listing page

lösung

I am trying to render a custom module **bleep** if it has been set

 

Here is the custom module markup on the listing page

{% text "resource-url" label='Resource URL', **bleep**='', export_to_template_context=True %}

and here is my conditional code for the blog listing, is == ' ' a correct way to check?

 

{% set rec_posts = blog_recent_posts('default', 4) %}
<div class="featured-posts">
{% for rec_post in rec_posts %}

{% if rec_post.widgets.resource-url.body.**bleep** == '' %} <div class="post-title"><h2><a href="{{ rec_post.absolute_url }}">{{ rec_post.name|truncate(37,true,'...') }}</a></h2></div> {% elif rec_post.widgets.resource-url.body.**bleep** != '' %} <div class="post-title"><h2><a href="{{ rec_post.widgets.resource-url.body.**bleep** }}">{{ rec_post.name|truncate(37,true,'...') }}</a></h2></div> {% else %} <div class="post-title"><h2><a href="{{ rec_post.absolute_url }}">{{ rec_post.name|truncate(37,true,'...') }}</a></h2></div> {% endif %}

 Currently the absolute_url is the **bleep** everytime

0 Upvotes
1 Akzeptierte Lösung
anders_grove
Lösung
Mitwirkender/Mitwirkende | Elite Partner
Mitwirkender/Mitwirkende | Elite Partner

Conditional Statement on Blog Listing page

lösung
{% text "resource_url" label='Resource URL', **bleep**='', export_to_template_context=True %}

{% if widget_data.resource_url.**bleep** %}
    <!--True-->
    <p>The custom widget has a **bleep**</p>
{% else %}
    <!--False-->
    <p>The custom widget doesn't have a **bleep**</p>
{% endif %}

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
2 Antworten
anders_grove
Lösung
Mitwirkender/Mitwirkende | Elite Partner
Mitwirkender/Mitwirkende | Elite Partner

Conditional Statement on Blog Listing page

lösung
{% text "resource_url" label='Resource URL', **bleep**='', export_to_template_context=True %}

{% if widget_data.resource_url.**bleep** %}
    <!--True-->
    <p>The custom widget has a **bleep**</p>
{% else %}
    <!--False-->
    <p>The custom widget doesn't have a **bleep**</p>
{% endif %}
0 Upvotes
InciteJoe
Mitwirkender/Mitwirkende | Gold Partner
Mitwirkender/Mitwirkende | Gold Partner

Conditional Statement on Blog Listing page

lösung

Ahh thank you, it was the name of my variable!

0 Upvotes