Forum Discussion

DavidO's avatar
DavidO
Strategist II
12 months ago

Is it possible to store liquid and content blocks inside catalogs?

Hi all

Recently we tried putting a section of liquid + text inside a catalog item but it only rendered as text. I then put it inside a content block and it seemed to render for the first item but if I had two items the second one didn't render. I'm not sure if I'm missing some tricks or it's not possible but I'm currently having issues getting it to render reliably each time. 

The longer end goal is to render a series of emails based on user paths but use catalogs as the single source of truth for content and avoid going in and out of a canvas. I know I can build the emails with HTML in the canvas and pull in the copy, that works good. Was just testing if I can pull in entire sections of code as well.

Open to any advice, tips and tricks.

Thanks šŸ˜Š

  • Stuart's avatar
    Stuart
    Practitioner III

    Hey DavidO,

    'Is it possible to store liquid and content blocks inside catalogs? '  Not in the way you have described. 

    If you wish to use a Catalog (so you can update 'items' (cells) with a CSV or via Catalog API or CDI) to control the content that is displayed to a user, I would recommend the following approach: 

    • Create a Catalog (e.g. 'Catalog-SSOT') and add a 'field' (column) name for each of the content areas of your email (e.g. header_img, header_cta etc).
    • Create a Content Block for each corresponding content areas of the email (e.g. header_img-content_block, header_cta-content_block etc) 
    • Within these content blocks, store the different content versions and add liquid, eg: 

    {{content_blocks.${header_img-content_block}}} : 

    {% catalog_items Catalog-SSOT  {{${user_id}}} %}

    {% if items[0].header_img == "Version1 " %}
    Version1header_img.png
    {% elsif  items[0].header_img == "Version2%}
    Version2header_img.png
    {% elsif  items[0].header_img == "Version3%}
    Version3header_img.png
    {% endif %}
     
    {{content_blocks.${header_cta-content_block}}} : 
    {% catalog_items Catalog-SSOT  {{${user_id}}} %}
    {% if items[0].header_cta == "Version1 " %}
    {% elsif  items[0].header_cta == "Version2%}
    {% elsif  items[0].header_cta == "Version3%}
    {% endif %}
    • Embed/Add each content block within your email template e.g:

    <a href="{{content_blocks.${header_cta-content_block}}}" ><img src="{{content_blocks.${header_img-content_block}}}" /></a>   

    • When a user preferences changes, update the 'version' within the 'Catalog-SSOT' catalog field/s (manually via CSV or via Catalog API or CDI)
    • When content versions change, update the corresponding content block (manually or via the content block endpoint)

    Example of 'Catalog-SSOT' fields and items:

    I hope this helps, Happy Xmas!

     

     

     

    • DavidO's avatar
      DavidO
      Strategist II

      This is a really clever way to manage this process Stuart! So the liquid is stored and running inside the content block, not the catalog, but the catalog determines output of that liquid. Nice. šŸ™

  • abenton's avatar
    abenton
    Practitioner II

    Hoping someone with an answer chimes in - also curious about this!