CMS Development

CLaflamme
Member

request.postDict.inpageEditorUI based logic

SOLVE

Hello everyone, 

I'm using the follow logic block to only show elements within the UI editor: 

{% if request.postDict.inpageEditorUI %}
# all the code I want to see in the editor here
{% endif %}

This works on initial load in the editor, but this widget uses cards - for example: 
{
"label": "Event Cards",
"name": "card",
"type": "group",
"occurrence": {
"default": 0,
"min": 0,
"sorting_label_field": "card.title"
},
"children": [ # all the other fields here...

Whenever I add a new card in my element, the 
request.postDict.inpageEditorUI variable becomes NULL and I can no longer see my cards.  Is there another variable I should be using for card editing to prevent this?  Or is an inverse option availabled, such as 'Not LIVE site OR Not preview site'?  If I refresh my page I can see the newly added cards again, but it seems there should be a solution for this and I can't find anything on 'request.postDict' in the hubspot docs anywhere. 
Thanks!


0 Upvotes
1 Accepted solution
Sjardo
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

request.postDict.inpageEditorUI based logic

SOLVE

Hi,

 

As the edit screen for post or blogs always have /edit/ in the url, you could target that piece of URL and based on the value (true or false), you can show things in the editor or not.

Make sure you get the current "path" with {{ request.path }}, to make sure you get the Editor URL instead of the page url

 

for example:

 

{% if request.path is string_containing "/edit/" %} Do something {% endif %}

 

 

Other options is use JS and check the current URL, but that's just an Google search away!

View solution in original post

1 Reply 1
Sjardo
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

request.postDict.inpageEditorUI based logic

SOLVE

Hi,

 

As the edit screen for post or blogs always have /edit/ in the url, you could target that piece of URL and based on the value (true or false), you can show things in the editor or not.

Make sure you get the current "path" with {{ request.path }}, to make sure you get the Editor URL instead of the page url

 

for example:

 

{% if request.path is string_containing "/edit/" %} Do something {% endif %}

 

 

Other options is use JS and check the current URL, but that's just an Google search away!