This recipe shows you how to use AdPlugg to place ads into the sidebar of your Shopify site's product list/catalog pages. These are the pages in your shopify site that show all of your products. They are usually accessed by clicking on "Shop" or "Catalog" in your site's header. Displaying ads on these pages is a great way to offer special promotions, suggest products from sponsoring manufacturers, etc.
Since the default Shopify theme, "Debut", doesn't have a sidebar for on the product list pages by default, this recipe will also show you how to add one!
You can see a demo of what the end result of this recipe looks like on the AdPlugg Shopify sample site here.
First, we need to create an AdPlugg Ad.
Next we are going to add the AdPlugg SDK to your Shopify Theme. This allows you to place and run AdPlugg ads throughout your Shopify site.
Now we are going to add a sidebar to your Shopify theme's product list/catalog pages. This is necessary for themes such as Shopify's default "Debut" theme.
<div class="page-width" id="Collection">
<div class="page-width">
<div class="grid">
<div class="grid__item medium-up--two-thirds">
<div id="Collection">
</div>
<div class="grid__item medium-up--one-third">
%%SIDEBAR%%
</div>
</div>
</div>
{% comment %}
The contents of the collection.liquid template can be found in /sections/collection-template.liquid
{% endcomment %}
{% capture sidebar_content %}
{% section 'custom-content' %}
{% endcapture %}
{% assign sidebar_content = sidebar_content | replace: 'class="shopify-section index-section"', 'class="shopify-section-nested index-section"' %}
{% capture template_content %}
{% section 'collection-template' %}
{% endcapture %}
{% assign template_content = template_content | replace: "%%SIDEBAR%%", sidebar_content %}
{{ template_content }}
Now if you open one of your product list pages, you should see a right sidebar with the default custom-content text. Read on for how to modify this and add your ads.
Now we are going to add our AdPlugg ad to the sidebar of our Shopify product list pages.
Your ads should now start serving into the right sidebar on your Shopify page!
In addition to ads, you can insert other content into your sidebar. You can do this for basic content such as text and images by customizing the custom content section as we did above. Or for more advanced content, you can do it by modifying your collection-template.liquid file.
Here's how to add a menu to your new sidebar.
First we are going to create the new menu from the Shopify admin.
Now we are going to add the new menu to the sidebar that we created in the steps above.
<h3 class="text-center">Browse</h3>
{% assign sidebar_link = linklists.sidebar-menu.links %}
<ul>
{% for sidebar in sidebar_link %}
<li><a href="{{ sidebar.url }}">{{ sidebar.title }}</a></li>
{% assign child_list_handle = sidebar.title | handleize %}
{% assign child_list = linklists[child_list_handle] %}
{% for child_link in child_list.links %}
<li><a href="{{ child_link.url }}">{{ child_link.title }}</a></li>
{% endfor %}
{% endfor %}
</ul>
You should now see your menu in the sidebar on your product list/catalog pages.
We have lots more Shopify recipes. Check them all out here.