Ecommerce Shopify WordPress Discussion

How to make banner

Here is the code that works but I need to make it efficient, as you can see to meet the condition I repeat the div after to check if the condiotion is met or not but I feel there should be a way to wrap the div without repeating the code First I assigned a variable: if block.settings.desktop!=blank assign link = true else assign link = false endif Then I use the variable to wrap with an anchor: {% if link %} <a href="{{ block.settings.desktop }}" aria-label="{{ block.settings.desktop }}"> <div class="hero-banner__content {{ banner_alignment }} {{ banner_alignment_mobile }}-- The question is
You can just use if-else to wrap anchor tag markup at the start and at the end. So if you have banner_link TRUE it will add an anchor tag otherwise it will not. {% if banner_link %} <a href="{{ block.settings.cta_link_desktop_1 }}" aria-label="{{ block.settings.cta_aria_desktop_1 }}"> {% endif %} // Your repeating code goes here single time :) <div class="hero-banner__content ...."> ... </div> {% if banner_link %} </a> {% endif %} if any doubt please comment.

December 31, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.