title: Is it possible to dynamically set the "featured" collection on a shopify store?
body: <p>I would like to be able to display two different collections in the featured products section on a shopify store. I would like to do this to avoid displaying a featured product that is the same as the product being viewed. I see that on the customize theme page it is possible to chose which collection to be displayed, but this collection cannot change. I believe the best way to do this is to use product tags and then change the featured collection based on the tag. However I have not had success. Any help here is greatly appreciated.</p>
  
  <pre><code>{% for tag in product.tags %}
  
      {% if tag contains 'top' %}
  
          {% assign settings.home_featured_products == 'Home' %}
  
      {% elsif tag contains 'bottom' %}
  
          {% assign settings.home_featured_products == 'Frontpage' %}
  
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
  <p>There is also a "featured-products.liquid" file that is included on the product page that controls the layout of the featured products section. It may be possible to create two of these files that show two different collections and then display the different files based on tags. However I am not sure how to control which collection is displayed in this file.</p>
  
  <pre><code>&lt;!-- snippets/featured-products.liquid --&gt;
  
  {% if section_number &gt; 1 and number_of_index_sections &gt; 1 %}
   &lt;hr class="hr--medium hr--clear"&gt;
  {% endif %}
  
  &lt;div class="section-header text-center"&gt;
    &lt;h1&gt;{{ 'home_page.sections.featured_products' | t }}&lt;/h1&gt;
    &lt;hr class="hr--small"&gt;
  &lt;/div&gt;
  
  &lt;div class="{% if settings.collection_products_grid == 'collage' %}grid grid-collage{% else %}grid-uniform{% endif %}"&gt;
  
    {% comment %}
      Loop through products in your Frontpage collection.
      This collection is created by default, but you must add products to it.
  
      See the snippet 'snippets/product-grid-collage.liquid'.
  
      `is_reverse_row_product`, `three_row_index_product`, `collection_product_count_product`, and `divisible_by_three_product` are
      all used by 'snippets/product-grid-collage.liquid'
    {% endcomment %}
    &lt;div class="grid-uniform__aligner"&gt;
    {% if settings.home_featured_products == blank or collections[settings.home_featured_products].empty? or collections[settings.home_featured_products].products_count == 0 %}
  
      {% comment %}
        For onboarding new users to your theme, we add some default products and onboarding tutorials to help populate their store
      {% endcomment %}
      {% unless emptyState %}
        {{ 'theme-onboarding.css' | global_asset_url | stylesheet_tag }}
        {% assign emptyState = true %}
      {% endunless %}
  
      {% include 'onboarding-featured-products' %}
  
    {% else %}
  
      {% if settings.collection_products_grid == 'collage' %}
  
        {% assign is_reverse_row__product = false %}
        {% assign three_row_index__product = 0 %}
        {% if collections[settings.home_featured_products].products_count &gt; 50 %}
          {% assign collection_product_count__product = 50 %}
        {% else %}
          {% assign collection_product_count__product = collections[settings.home_featured_products].products_count %}
        {% endif %}
        {% assign divisible_by_three__product = collection_product_count__product | modulo:3 %}
  
        {% for product in collections[settings.home_featured_products].products %}
          {% include 'product-grid-collage' %}
        {% endfor %}
  
      {% else %}
  
        {% assign grid_item_width = 'medium--one-half large--one-third' %}
        {% for product in collections[settings.home_featured_products].products %}
          {% include 'product-grid-item' %}
        {% endfor %}
  
      {% endif %}
  
    {% endif %}
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>