Product block with image and description next to each other [Showcase theme]

Dear community,

I am trying to change the layout of the product block in my featured collection to show the image on the left and the description on the right side next to it, instead of image and then description below one another. I know this must be possible by adding some flex containers to the product-block code but I cannot figure out what to add where … Any hint will be greatly appreciated!

{%- liquid
  assign cheapest_variant = product.variants | sort: 'price' | first

  assign on_sale = false
  if cheapest_variant.compare_at_price > cheapest_variant.price
    assign on_sale = true
  endif

  assign product_url = product.url | within: collection

  if animation_type == blank
    assign animation_type = "cc-fade-in-up"
  endif

  assign primary_image = product.featured_media.preview_image
  assign secondary_image = product.media[1].preview_image

  if settings.prod_show_videos
    assign videos = product.media | where: "media_type", "video"
    unless videos == blank
      for source in videos[0].sources
        if source != blank and source.format == "mp4"
          assign video_source = source
          break
        endif
      endfor

      assign mp4_url = video_source.url
    endunless
  endif

  assign product_has_swatches = false
  if settings.swatch_enabled and settings.prod_block_swatches and hide_swatches != true
    for product_option in product.options_with_values
      if settings.swatch_option_name == product_option.name
        assign product_has_swatches = true
        break
      endif
    endfor
  endif

  assign param_symbol = "?"
  if product.url contains "?"
    assign param_symbol = "&"
  endif
-%}

 1 %}all-images{% endif %}
  {% if product.tags contains 'meta-layout-right' %}layout-right{% endif %}
  {% if settings.prod_label_layout == 'marquee_on_hover' %} product-block--marquee-on-hover {% endif%}
  {% if settings.quickbuy_enabled %}product-block--quickbuy{% endif %}
  {% if mp4_url != blank %}product-block--video{% endif %}
  {% if product_has_swatches %}product-block--has-swatches{% endif %}
  {{ product_class }}"
     data-loop-index="{{ i }}"
  {% if animate %} data-cc-animate="{{ animation_type }}" data-cc-animate-delay="{{ animate | times: 0.15 }}s" {% endif %}

  {% if product.images.size > 1 %}
    {% if settings.prod_hover == "all_images" or product_has_swatches %}
      {%- liquid
        assign images = ""
        for image in product.images
          assign image_placeholder = image | img_url: '1x1' | replace: '_1x1.', '_{width}x.'
          assign images = images | append: "," | append: image_placeholder
        endfor
      -%}
      data-product-images="{{ images | remove_first: "," }}"
    {% endif %}
  {% endif %}
>

  

    
 1 %}image--hover-second {% if primary_image.aspect_ratio == secondary_image.aspect_ratio %}image--same-aspect-ratio{% endif %}{% endif %}">
      {% if settings.prod_label_layout contains 'marquee' %}
        

          {% render 'product-label', product: product, cheapest_variant: cheapest_variant %}
        

      {% endif %}

      
        

          {% if mp4_url != blank %}
            {% render 'inline-video', video: mp4_url, image: primary_image %}
          {% else %}
            {% render 'responsive-image', image: primary_image %}
          {% endif %}

          {% unless settings.prod_label_layout contains 'marquee' %}
            {% render 'product-label', product: product, cheapest_variant: cheapest_variant %}
          {% endunless %}
        

        {% if settings.prod_hover == "second_image" and product.media.size > 1 %}
        
          {% render 'responsive-image', image: secondary_image, aspect_ratio: primary_image.aspect_ratio %}
        

        {% endif %}
      
    

    {%- if settings.swatch_enabled and settings.prod_block_swatches and hide_swatches != true -%}
      {%- assign option_limit = 3 -%}
      {%- for product_option in product.options_with_values -%}
        {%- if settings.swatch_option_name == product_option.name -%}
          
            {%- if product.options.size == 1 -%}
              {%- for variant in product.variants -%}
                {%- assign variant_image = variant.featured_media.preview_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
                {% if forloop.index <= option_limit %}
                  - {{ variant.title }}
                  
                  

                {% endif %}
              {%- endfor -%}
              {%- if product.variants.size > option_limit -%}
                - +{{ product.variants.size | minus: option_limit }}

              {%- endif -%}
            {%- else -%}
              {%- assign product_option_position_0index = product_option.position | minus: 1 -%}
              {%- for product_option_value in product_option.values -%}
                {%- liquid
                  assign option_value_variant = false
                  assign is_unavailable = true
                  for variant in product.variants
                    if variant.options[product_option_position_0index] == product_option_value
                      assign option_value_variant = variant
                      break
                    endif
                  endfor
                  for variant in product.variants
                    if variant.available and variant.options[product_option_position_0index] == product_option_value
                      assign is_unavailable = false
                      break
                    endif
                  endfor
                  assign variant_image = option_value_variant.featured_media.preview_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.'
                -%}
                {% if forloop.index <= option_limit %}
                  - {{ product_option_value }}
                    
                  

                {% endif %}
              {%- endfor -%}
              {%- if product_option.values.size > option_limit -%}
                - +{{ product_option.values.size | minus: option_limit }}
              {%- endif -%}
            {%- endif -%}
          

        {%- endif -%}
      {%- endfor -%}
    {%- endif -%}

    {%- if settings.quickbuy_enabled -%}
      
        
          {{ 'products.listing.quick_view' | t }}
        
      

    {%- endif -%}

    
    
      {% if show_custom_title %}
       {{ product.metafields.custom.farbe }}
      {% else %}
      {{ product.title }}      
      {% endif %}

      {% if show_vendor %}
        {{ product.vendor }}
      {% endif %}

      

        {% if product.price_varies %}{{ 'products.listing.from' | t }}{% endif %}
        {%- render "price", price: cheapest_variant.price -%}
        {% if on_sale %}{%- render "price", price: cheapest_variant.compare_at_price -%}{% endif %}

        {% render 'unit-price', variant: cheapest_variant %}
      

    

    {% if settings.show_product_block_reviews %}
    
      {% render 'rating', rating_value: product.metafields.reviews.rating.value %}
      {% if product.metafields.reviews.rating_count != blank and product.metafields.reviews.rating_count > 0 %}
        
          {{ product.metafields.reviews.rating_count }} {{ 'products.product.reviews_link' | t: count: product.metafields.reviews.rating_count | downcase }}
        
      {% endif %}
    
    {% endif %}
        
  

Hi @lenarei ,

It can only be displayed like this:

If you want to display color list, it will be more complicated and time consuming so you need to hire experts for it. Refer https://community.shopify.com/c/Shopify-Ecommerce-Jobs/bd-p/shopify-job-board

Do you want this?

Hey @LitExtension ,

Thanks for your answer! I managed to get the items aligned next to one another, also displaying the color swatches. My only issue is that I would like to add some white margin on the sides that will be displayed on desktop, but not on mobile.


 
  {% if section.settings.title != blank %}
    

      ## {{ section.settings.title | escape }}
    

  {% endif %}
      
  {% for block in section.blocks %}
   {% style %}
    {% if block.settings.color_scheme == "custom" %}
      .block-id-{{ block.id }} {
        background: {{ block.settings.color_bg }};
        --cust-text-color: {{ block.settings.color_text }};
       border-radius: 24px;
      }
    {% endif %}

    #block-id-{{ block.id }} .section-rich-text__image .rimage-outer-wrapper {
      width: {{ block.settings.image_width }}px;   
    }         
  {% endstyle %}

        
 

  
        
   
      
    

      
     
        
      {% if block.settings.title != blank %}
        ## 
          
            {{ block.settings.title | escape }}
          
        
      {% else %}
          

      {% endif %} 
     

    
     
      {% if block.settings.image != blank %}
        

          {%- render 'responsive-image', image: block.settings.image -%}
        

      {% endif %} 
     

   

 

           
      {% if block.settings.collection != blank %}
        {% assign collection = collections[block.settings.collection] %}
        {% for product in collection.products limit: max_products %}
          {% render 'product-block-horizontal', product: product, product_class: product_class, animation_type: animation_type, i: forloop.index, show_vendor: block.settings.show_vendor, show_custom_title: section.settings:show_custom_title, animate: forloop.index, hide_swatches: section.settings.hide_swatches %}
        {% endfor %}
      {% endif %} 
     
      

    

  {% endfor %}

{% schema %}
{
  "name": "Text columns with media",
  "class": "section-text-columns-with-images",
  "settings": [
    {
      "type": "text",
      "id": "title",
      "label": "Heading",
      "default": "Text columns with media"
    },
    {
      "type": "select",
      "id": "text_alignment",
      "label": "Heading alignment",
      "options": [
        {
          "value": "left",
          "label": "Left"
        },
        {
          "value": "center",
          "label": "Center"
        },
        {
          "value": "right",
          "label": "Right"
        }
      ],
      "default": "left"
    },
      {
        "type": "checkbox",
        "id": "hide_swatches",
        "label": "Hide color swatches",
        "default": false
      },   
      {
        "type": "checkbox",
        "id": "show_custom_title",
        "label": "Show custom title (metafield)",
        "default": false
      }    
  ],
  "blocks": [
    {
      "type": "text_block",
      "name": "Column",
      "settings": [
      {
        "type": "text",
        "id": "title",
        "label": "Heading",
        "default": "Featured collection"
      },
      {
        "type": "image_picker",
        "id": "image",
        "label": "Image"
      },
      {
        "type": "range",
        "id": "image_width",
        "min": 50,
        "max": 150,
        "step": 10,
        "label": "Image width",
        "unit": "px",
        "default": 70
      },
      {
        "type": "collection",
        "id": "collection",
        "label": "Collection"
      },
      {
        "type": "select",
        "id": "layout",
        "label": "Layout",
        "options": [
          {
            "value": "columns",
            "label": "Collage"
          },
          {
            "value": "rows",
            "label": "Grid"
          }
        ],
        "default": "rows",
        "info": "Collage will only work when the 'Image shape' is set to Natural - in Products / Image shape"
      },        
      {
        "type": "radio",
        "id": "color_scheme",
        "label": "Color scheme",
        "default": "standard",
        "options": [
          {
            "value": "standard",
            "label": "Standard"
          },
          {
            "value": "alt",
            "label": "Alternate colors"
          },
          {
            "value": "custom",
            "label": "Custom colors"
          }
        ]
      },
      {
        "type": "color",
        "id": "color_bg",
        "label": "Custom background color"
      },
      {
        "type": "color",
        "id": "color_text",
        "label": "Custom text color"
      }    
      ]
    }
  ],
  "presets": [
    {
      "name": "Test für gestapelte Sections",
      "settings": {
      },
      "blocks": [
        {
          "type": "text_block"
        },
        {
          "type": "text_block"
        },
        {
          "type": "text_block"
        }
      ]
    }
  ]
}
{% endschema %}

:thinking:

Hi @lenarei ,

Please send your site and if your site is password protected, please send me the password. I will check it.

I am currently testing this on a copy of my theme, please find the preview to it here: https://mph36nt18hu3rfke-60850798810.shopifypreview.com

Hi @lenarei ,

This preview link has expired. Can you send me a new link?

1 Like

Of course, here is a new preview link: https://sbki1r47gn4k3w9v-60850798810.shopifypreview.com

Hi @lenarei ,

Go to Assets > styles.css and paste this at the bottom of the file:

#block-id-165960027152be7d50-0 .product-block {
    padding: 8px 15px !important;
}
#block-id-165960027152be7d50-0 .product-block .flex-container {
    gap: 15px !important;
}

Hope it helps!

Hi @LitExtension ,

Thanks so much for your input. I added this to the CSS but it doesn’t seem to have any effect at all - the section still looks the same as before :thinking:

Hi @lenarei ,

I don’t understand, you don’t want to add spacing for this?

Let me try and be clearer then :slightly_smiling_face: What I would like to do is add some whitespace on the left and right of these blocks in the desktop version. So eventually, it shall look something like this:

Hi @lenarei ,

Go to Assets > styles.css and paste this at the bottom of the file:

@media (min-width: 768px) {
	#block-id-165960027152be7d50-0 {
		margin-left: 70px;
		margin-right: 35px;
		width: calc(50% - 105px);
	}
	#block-id-165960027152be7d50-1 {
		margin-left: 35px;
		margin-right: 70px;
		width: calc(50% - 105px);
	}
}
@media (min-width: 1441px) {
	#block-id-165960027152be7d50-0 {
		margin-left: 90px;
		margin-right: 45px;
		width: calc(50% - 135px);
	}
	#block-id-165960027152be7d50-1 {
		margin-left: 45px;
		margin-right: 90px;
		width: calc(50% - 135px);
	}
}

Hope it helps!

Thanks so much for your input, I appreciate your help! Unfortunately this doesn’t make any difference either :confused: I tried adding some margin to the column block, but this will cause the blocks to no longer be aligned next to each other, but lets them jump to a second line …

Hi @lenarei ,

I checked and it shows fine, have you checked it again?

Interesting! It still looks like this for me, no matter what browser I check on:

Hi @lenarei ,

Can you send me the preview link, I will check it again.

Thanks @LitExtension for your kind help! Here is a new preview link: https://fxmdnl6deipbtgtn-60850798810.shopifypreview.com

Hi @lenarei ,

Please change code:

@media (min-width: 768px) {
	#block-id-165960027152be7d50-0 {
		margin-left: 70px !important;
		margin-right: 35px !important;
		width: calc(50% - 105px) !important;
	}
	#block-id-165960027152be7d50-1 {
		margin-left: 35px !important;
		margin-right: 70px !important;
		width: calc(50% - 105px) !important;
	}
}
@media (min-width: 1441px) {
	#block-id-165960027152be7d50-0 {
		margin-left: 90px !important;
		margin-right: 45px !important;
		width: calc(50% - 135px) !important;
	}
	#block-id-165960027152be7d50-1 {
		margin-left: 45px !important;
		margin-right: 90px !important;
		width: calc(50% - 135px) !important;
	}
}

@LitExtension - I changed the code accordingly but it still doesn’t cause any effects sadly

I found a solution - I added some white border to the boxes on desktop only. It’s not perfect, but a good workaround

.column-border{}
@media (min-width: 768px) {
     .column-border{
     border: solid; 
     border-color: #fff; 
     border-width: 20px; 
     border-radius: 40px !important;
}     
}