PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, June 30, 2022

[FIXED] How do I add external links in Shopify Schema?

 June 30, 2022     shopify     No comments   

Issue

I've tried using "type": "url:". and apparently that only works for collections. I want to make a dynamic external link. I tried text input. Why is this one task not easy to do?

 <a class="section-tiktok__card" href="{{block.settings.url}}">
            <img src="{{ 'tik-play-btn.svg' | asset_url }}" alt="play video">
        </a> 


{% schema %}
    {
    "name": "TikTok Feed",
    "presets": [{
        "name": "TikTok Section"
    }],

    "blocks": [{
        "type": "html",
        "limit": 5,
        "name": "TikTok and Instagram Feed",
        "settings": [
            {
                "type": "image_picker",
                "id": "tiktok_bg",
                "label": "Image Background"
            },
            {
                "type": "url",
                "id": "tiktok_url",
                "label": "Tiktok or Instagram URL"
            }
        ]
    }]
}


{% endschema %}```

Solution

You're attempting to get a setting from a block but you haven't accessed your section blocks or assigned anything to block. Furthermore, your setting is named tiktok_url while you're using url to display it.

{% for block in section.blocks %}
    <a class="section-tiktok__card" href="{{ block.settings.tiktok_url }}" {{ block.shopify_attributes }}>
        <img src="{{ 'tik-play-btn.svg' | asset_url }}" alt="play video">
    </a> 
{% endfor %}


Answered By - Nathan Dawson
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing