Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I'm getting started on a new liquid page template where some secret content should be visible to customers with the tag 'Active'. Any customers without the tag should see a 'not allowed' message. I also want to be sure that while editing the site, admins/editors are able to preview both sections in order to edit content for either case. The main issue seems to be displaying the 'not allowed message' outside of the Theme Customizer but I'm not sure where to go from here. Here is my logic and current output:
{% unless customer.tags contains 'Active' %} {% section 'not-allowed-message' %} {% endunless %} {% if customer.tags contains 'Active' or request.design_mode or content_for_header contains 'AdminBarInjector' %} {% section 'secret-content' %} {% endif %}
Location | Output | Expected |
Theme Customizer | Both | Both |
Preview Store while signed in as an admin/editor | Secret Content only | Both |
Preview Store while signed out/in incognito | Nothing | Not Allowed Message only |
Preview Store while signed in as a customer with the 'Active' tag | Secret Content only | Secret Content only |
Any help or suggestions are greatly appreciated!
Solved! Go to the solution
This is an accepted solution.
I use this to show only in preview mode:
{% if content_for_header contains "previewBarInjector.init()" %}
<p>This shows only in preview mode</p>
{% endif %}
This is an accepted solution.
I use this to show only in preview mode:
{% if content_for_header contains "previewBarInjector.init()" %}
<p>This shows only in preview mode</p>
{% endif %}
Thank you! I still have no idea why the unless portion of the code was not originally working, but after replacing AdminBarInjector with previewBarInjector.init(), the logic worked about as expected. There's one caveat, however it's something I can look past unless my client specifically comes back and asks for it.
Location | Output | Expected |
Preview Store while signed in as an admin/editor | Not Allowed Message only | Both |
Thanks again for your help!
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025