Reputation: 12867
We have some very large articles (HTML content) as long as 2000 words that need to be loaded and displayed at an arbitrary place in the Shopify theme, for example, at the bottom of a specific collection.
For now, we are saving them as snippets .liquid files that are conditionally loaded at the bottom of the collection template by:
{% if collection.handle == 'collection-abc' %}
Article 1 HTML goes here...
{% elsif collection.handle == 'collection-def' %}
Article 2 HTML goes here...
{% endif %}
Is it possible to here load the content of a specific page by handle? So it's easier for our editors and writers to work in the Shopify page editor otherwise we have to give them permission to edit theme code which isn't ideal in many ways.
Neither is creating a theme section helpful here since the content is too long to be comfortably edited in the theme customizer. It's not secure either as the writer will have access to theme customization.
Is there any better way & intended way to achieve this?
Upvotes: 0
Views: 3522
Reputation: 1132
There are multiple ways to achieve this behavior.
{% for article in blogs["news"].articles %}
{% if article.handle contains collection.handle %}
{{ article.content }}
{% endif %}
{% endfor %}
{{ pages[collection.handle].content }}
{{ collection.description }}
Upvotes: 2