- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Making a module inside an if statement visible to page editors
SOLVEFeb 8, 2017 9:11 PM
Hi there,
I'm working on an email template that has a {{rich_text}} module inside an if statement, like this:
{% boolean "show_bottom_callout" label="Show bottom callout", no_wrapper=True, export_to_template_context=True %} {% if widget_data.show_bottom_callout.value == true %}
{% widget_block rich_text "bottom_callout_content" overrideable=True, label='Bottom callout content', no_wrapper=True %} {% widget_attribute "html" %} {% end_widget_attribute %} {% end_widget_block %}
{% endif %}
Now, when I use this template, the rich text module is not visible/editable until the boolean has been turned on, and the page has been refreshed. This adds confusion for an editor who might not be aware that the text is editable (after refresh).
Rich text element is not visible until toggle is turned on AND the user refreshes the page.Does anyone have a suggestion for how I can show the rich text module to editors even if the boolean is false?
Or is this just a bug?
Thanks for your help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Feb 9, 2017 10:13 AM
Here's a hack that uses CSS to hide it when boolean is false. I tested and seems to work not requiring a page refresh.
{% boolean "show_bottom_callout" label="Show bottom callout", no_wrapper=True, export_to_template_context=True %} <div class="{% if widget_data.show_bottom_callout.value == false %}hide-callout{%endif%}"> {% widget_block rich_text "bottom_callout_content" overrideable=True, label='Bottom callout content', no_wrapper=True %} {% widget_attribute "html" %} Content {% end_widget_attribute %} {% end_widget_block %} </div> <style> .hide-callout { display: none; } </style>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Feb 13, 2017 3:51 PM
Your missing export_to_template context which exports the module data to the template so it can be called else where.
{% widget_block rich_text "bottom_callout_content" overrideable=True, label='Bottom callout content', no_wrapper=True, export_to_template_context=True %} {% widget_attribute "html" %} CONTENT RENDERS WHEREVER I PUT THIS STATEMENT, OF COURSE {% end_widget_attribute %} {% end_widget_block %}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Feb 13, 2017 3:55 PM
need to add export_to_template_context = true to module.
{% widget_block rich_text "bottom_callout_content" overrideable=True, label='Bottom callout content', no_wrapper=True, export_to_template_context = true %}
The only challenge to this method is you can only edit the "bottom callout content" from the module editor pane on the left as it is a hidden module.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content