Showing posts with label Dynamic. Show all posts
Showing posts with label Dynamic. Show all posts

Thursday 26 October 2023

Shopify - Add dynamic links on description

{% assign productdescription = product.description %}

{% assign productdesclinks = "maxi dress~https://examples.com/collections/maxi-dresses,midi dress~https://examples.com/collections/midi-length-dresses,midi~https://examples.com/collections/midi-length-dresses,pockets~https://examples.com/collections/dresses-with-pockets,kasey rainbow~https://examples.com/collections/kasey-rainbow,maggi~https://examples.com/collections/maggi-mcdonald-x-proud-poppy ,Maggi McDonald~https://examples.com/collections/maggi-mcdonald-x-proud-poppy,spring~https://examples.com/collections/spring-dresses-collection ,floral~https://examples.com/collections/floral-dresses" %}

{% assign productdesclinks = productdesclinks | split: ',' %}

{% for productdesclink in productdesclinks %}

  {% assign productdesclk = productdesclink | split: '~' %}

  {% assign productdesclkcomp = productdesclk[0] %}

  {% assign productdesclkurl = productdesclk[1] %}

  {% assign productdesclklink = '<a href="' | append: productdesclkurl | append: '">' | append: productdesclkcomp | append:"</a>" %}

  {% assign productdescription = productdescription | replace:productdesclkcomp, productdesclklink %}

{% endfor %}

{{ productdescription }} 




Saturday 31 October 2020

How to create simple dynamic section with block in Shopify liquid in theme

add {% section 'contactpagefaq' %} on your template file

Create new section file called : contactpagefaq.liquid, and paste following code.

{% if section.settings.faqenable %}
<h2>{{ section.settings.faqtitle }}</h2>   

  {% for block in section.blocks %}  
  
  <button class="accordion">{{ block.settings.sectiontitle }}</button>
          <div class="panel">
            <p>{{ block.settings.sectiontext }}</p>
          </div>
  {% endfor %}
{% endif %}
{% schema %}
{
  "name": "Contact Page FAQ",
  "max_blocks": 5,
  "settings": [
{
          "id": "faqenable",
          "type": "checkbox",
          "label": "Enable",
          "default": true
        },
        {
          "id": "faqtitle",
          "type": "text",
          "label": "Heading",
          "default": "FAQ"
        }
      ],
  "blocks": [
    {
      "type": "select",
      "name": "Block",
      "settings": [
{
          "id": "sectiontitle",
          "type": "text",
          "label": "Title"
        },
        {
          "id": "sectiontext",
          "type": "textarea",
          "label": "Text"
        }
      ]
    }
  ]
}
{% endschema %}

{% stylesheet %}
{% endstylesheet %}

{% javascript %}
{% endjavascript %}