Capturing Article.Handle and using it to find a Collection with that handle

Solved

Capturing Article.Handle and using it to find a Collection with that handle

Nigel_Burke
Shopify Partner
67 2 4

Hi all. I'm a bit stuck on this one. I've done something before but cannot for the life of me remember how to do it. Any help is greatly apprecited.

 

I'm trying to show a Collection on a Blog Article Page. The Collection I need to show has the same handle as the blog article.

 

The Article handles will be along the lines of 'nigel-burke'. So the Collection I am trying to show on that Article page is called 'Nigel Burke' along with '-ambassador' at the end of the handle too. I'm then wanting to show the products in that particular collection on that particular article page.

 

This is the code I am trying to use...

 

{% capture my_variable %}{{ article.title | downcase | replace: ' ','-' | append: '-ambassador'}}{% endcapture %}

<div class='ambassador-collection'>
{% for product in collections.[my_variable].products %}
{{ product.title }}
{% endfor %}
</div>

 

But it's not working. Any help is greatly appreciated.

 

Nigel

 

Accepted Solutions (2)

PageFly-Kate
Shopify Partner
1373 375 428

This is an accepted solution.

Hi @Nigel_Burke ,

 

This is Kate from PageFly - Landing page builder, I’d like to suggest this idea:
You can try below code:

{% capture my_variable %}{{ article.handle | append: '-ambassador'}}{% endcapture %}

<div class='ambassador-collection'>
{% for product in collections[my_variable].products %}
{{ product.title }}
{% endfor %}
</div>

I hope it would help you
Best regards,

Kate | PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


Unlock the secrets to a record-breaking BFCM with PageFly and Canva


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available)


➜ Weekly updated Shopify tutorials on YouTube


All features are available from the Free plan. Live Chat Support is available 24/7.


View solution in original post

Nigel_Burke
Shopify Partner
67 2 4

This is an accepted solution.

Kate, thank you for taking the time to help me with this. 

 

I managed to get it working with your help, thanks. There was a little change needed here and there as you weren't to know a few things it needed to do too.

 

You set me off in the right direction though, so thank you again!

 

This is how it ended up working for me...

 

{% capture my_variable %}{{ article.title | downcase | replace: ' ','-' | append: '-ambassador'}}{% endcapture %}

<div class='ambassador-collection'>
{% for product in collections[my_variable].products %}
{{ product.title }}
{% endfor %}
</div>

View solution in original post

Replies 2 (2)

PageFly-Kate
Shopify Partner
1373 375 428

This is an accepted solution.

Hi @Nigel_Burke ,

 

This is Kate from PageFly - Landing page builder, I’d like to suggest this idea:
You can try below code:

{% capture my_variable %}{{ article.handle | append: '-ambassador'}}{% endcapture %}

<div class='ambassador-collection'>
{% for product in collections[my_variable].products %}
{{ product.title }}
{% endfor %}
</div>

I hope it would help you
Best regards,

Kate | PageFly

Please let me know if it works by giving it a Like or marking it as a solution!


Unlock the secrets to a record-breaking BFCM with PageFly and Canva


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available)


➜ Weekly updated Shopify tutorials on YouTube


All features are available from the Free plan. Live Chat Support is available 24/7.


Nigel_Burke
Shopify Partner
67 2 4

This is an accepted solution.

Kate, thank you for taking the time to help me with this. 

 

I managed to get it working with your help, thanks. There was a little change needed here and there as you weren't to know a few things it needed to do too.

 

You set me off in the right direction though, so thank you again!

 

This is how it ended up working for me...

 

{% capture my_variable %}{{ article.title | downcase | replace: ' ','-' | append: '-ambassador'}}{% endcapture %}

<div class='ambassador-collection'>
{% for product in collections[my_variable].products %}
{{ product.title }}
{% endfor %}
</div>