Is there a HubL way to create a if statement that detects if the User is editing a blog post in the editor or if a user has opened the live version of the blog post. I was unable to find this on Google or in any of the hubspot docs.
The reason I need this is that I want do display different code in the editor compared to the live blog post.
The editor iframes the content in on the preview side.... something like this should do the trick:
{% if request.full_url is string_containing "preview.hs-sites.com/content-rendering/" %}
//this would only display within the content editor
{% else %}
//this would show everywhere but the content editor
{% endif %}
-- Bryan Schneidewind Manager of Web Development Weidert Group
The editor iframes the content in on the preview side.... something like this should do the trick:
{% if request.full_url is string_containing "preview.hs-sites.com/content-rendering/" %}
//this would only display within the content editor
{% else %}
//this would show everywhere but the content editor
{% endif %}
-- Bryan Schneidewind Manager of Web Development Weidert Group
I already thought about using Javascript to detect the editor by checking the browser URL (your way is better though).
But that would lead to a lot of unnecessary, invisible HTML Code in my case.
My customers design draft for the blog listing page displays blog posts as boxes with image, headline and teaser, but also has several other types of editable boxes that should show up in between blog post boxes and on other parts of the listing page.
For normal blog posts that design works perfectly well, but the other types of boxes are a bit of an issue.
My idea was to make all types of boxes "blog posts" so a person can edit the content without having to edit the templates. And it would be impossible to add boxes somewhere in the post listing for loop any other way.
By tagging posts with different types of tags (like "product", "externalLink, ...) I could then display different HTML Code for a box that is not a normal blog post on the listing page, depending on what tag is set for the post. That would not lead to invisible code on the listing page, but if I want the person editing the box/blog post to see the content as it would appear ont he listing page, I would have to add HTML code for all types of boxes (in addition to the normal blog post code) to the blog post templates and then only show the part for the specific content type.
The customer is used to being flexible with layouts from using a enterprise CMS system, but Hubspot is not flexible at all 🙂 At least the blog isn't.
Anyway, if there is no editor HubL detection I will have to go the JS way.