HUBL query for if in "edit mode"

SOLVE
Manobyte
Participant | Diamond Partner

I have a few sections that use conditional logic to display different modules on a page, however this creates some issue with the modules not being there when you edit the page. So i'm looking for a way using hubl logic to determine if the page is being edited then show all the modules. I noticed there are some css classes that are different in edit mode and I have in the past used a method where all motions are conditionally hidden with css and shown in the editor, but I would much prefer if I can just use hubl to remove them entirely to prevent bloat from additional unnecessary html. If anyone has any ideas let me know!

0 Upvotes
1 Accepted solution

Accepted Solutions
piersg
Solution
Key Advisor

You can do this:

{% if request.postDict.inpageEditorUI %}
  {# will only display if page is being viewed in the editor #}
{% endif %}

 

View solution in original post

3 Replies 3
webdew
Top Contributor | Diamond Partner

Hi @Manobyte ,

Use Boolean option. See SS: https://prnt.sc/1521i0l and on/off module with editor.

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards. 

Manobyte
Participant | Diamond Partner

I am looking for more of a template solution rather then a custom module one. I know how to show/hide the content (Im dealing with global content that changes based on language), but if a module is hidden this way then it becomes un editable when editing the page, and only the options that meet the current requierment are available. It could potentualy all be moved into a single custom module but then you lose the other templeting benifits of having individule modules for the content.

I was thinging that maybe using export_to_template_context might be an option, this would atleast make the modules available in the side bar, but you would lose the ability to just "click" to edit the module, and you would not be able to visually see the updates untill published.

0 Upvotes
piersg
Solution
Key Advisor

You can do this:

{% if request.postDict.inpageEditorUI %}
  {# will only display if page is being viewed in the editor #}
{% endif %}

 

View solution in original post