Help me output within output {{ pages.{{ product.tags.first }}.content }}

Highlighted
Explorer
68 0 4

short: How do I display, as a link, on the product-card-list, the content of a page like: {{ pages.{{ product.tags.first }}.content }}

 

long: I have pages that correspond with products. Say I have Page called 1234 and Product with the tag 1234. On the (Debut) product-card-list, I want the content of the corresponding page 1234 to display with the corresponding product 1234. (And I need this to be an a href.) I have figured out where to put this, just not "how" because it's like I'm outputing within an output...

I have this so far but it doesn't work...

 

<a href="some-website-url">{{ pages.{{ product.tags.first }}.content }}">Title></a>

Thank!!

0 Likes
Highlighted

Try this @tesstesting 

{% assign tag =  product.tags.first %}
<a href="some-website-url">{{ pages[tag].content }}">Title></a>
Available for hiring. Inbox me lixonic[at]gmail[dot]com
2 Likes
Highlighted
Explorer
68 0 4

...sorry don't know how to delete replies yet...

0 Likes
Highlighted
Explorer
68 0 4

@Lixon_Louis

 


{% assign tag =  product.tags.first %}
<a href="some-website-url">{{ pages[tag].content }}">Title></a>

Okay, when I use your code exactly it kind of works? The URL works but not the "title"...this is what it outputs on the product-list...

right url (some-website-url), wrong title...

">Title

 

So I tried:

<a href="some-website-url>{{ pages[tag].content }}">Title</a>

This outputs the correct "title" but not the right URL

right title, wrong url (some-website-url>)

 

Meanwhile, the "title" is the same as the pages[tag].content...so I'm thinking something more like this would be better but it doesn't work:

{% assign tag =  product.tags.first %}
<a href="https://some-website/[tag]">{{ pages[tag].content }}</a>

All I'm really trying to do is insert product.tags.first into some-website/ and pages.content, if that makes sense?

0 Likes
Highlighted
Shopify Partner
578 124 202

@tesstesting 

 

Code is correct, I think you added the wrong product tag. You must have to add page handle as a tag. For example, a page with the handle about-us would have the url http://yourshop.myshopify.com/pages/about-us. so if you want to display about us page content then you must have add "about-us" as a product tag.

{% assign tag =  product.tags.first %}
<a href="https://some-website/pages/{{tag}}">{{ pages[tag].title}}</a>

 

Thank you,

Tejas

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
1 Like
Highlighted
Explorer
68 0 4

@Tejas_Nadpara 

 

Thanks Tejas, I'm having a lot of trouble with this.

 

So nothing shows up on my product-card-list when I use your suggested code:


{% assign tag =  product.tags.first %}
<a href="https://some-website/pages/{{tag}}">{{ pages[tag].title}}</a>

This may be problem on my end somehow? I've been trying different codes, only time a "title" shows up on my product-card-list is if I follow @Lixon_Louis code structure:

{% assign tag =  product.tags.first %}
<a href="some-website-url">{{ pages[tag].content }}">Title></a>

So if I try your code with this structure, I think it would be:

{% assign tag =  product.tags.first %}
<a href="https://some-website/pages/">{{tag}}">{{ pages[tag].title}}></a>

Now, something does show on my product-card-list, this is what I see.

some-product-tag-first">>

 

So, it does return the correct product.tag.first, but theres an additional ">> tacked on...and it links to https://some-website/pages/, not including >{{tag}}"...

 

Hope this makes sense...

To clarify, I want something like this, but it doesn't work:

 

{% assign tag =  product.tags.first %}
<a href="https://my-website/collections/">{{tag}}">{{ pages[tag].content}}></a>

 

So the URL I need links to a collection, with a title that is content from a page, using [tag] from a product that matches the collection title and page title. (Reading this made me laugh, and I'm wondering if I should figure out a simpler way to do this)...

0 Likes
Highlighted
Shopify Partner
578 124 202

@tesstesting 

 

confused! would you like to add page link or collection link? I think you want to display a collection name with link and manage it from product tag.

so for example, if there is collection name "Men Clothes" with url https://my-website/collections/men-clothes

now if you want to display this collection name in your product page then you have to add tag "men-clothes" in that product tag

then use the following code:

{% assign tag =  product.tags.first %} 
<a href="https://my-website/collections/{{tag}}">{{ collections[tag].title }}</a>

Output would be:

<a href="https://my-website/collections/men-clothes">Men Clothes</a>

Let me know if I misunderstood.

 

Thank you,

Tejas

 

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
0 Likes
Highlighted
Explorer
68 0 4

@Tejas_Nadpara 

 

Thanks for this, you basically summed it up:

I think you want to display a collection name with link and manage it from product tag.

 

 But I also want the title of said link to be the output of pages.some-page.content. Is this even possible?

 

Your code outputs Collection[tag].title as the link title but I want to output page[tag].content.

 

Probably best if I give you an example.
For instance, I have:

Product “ABC,” with

tags.first “ABC” and a

Collection called ABC and a

Page called ABC-Description with

page.description that says “ABC”

 

I need the collection link to have a title that is {{ pages.ABC.content }} like this:

<a href="...">{{ pages[tag].content}}></a>

This is where my problem is, I don’t know if it’s possible on product-card-list?

 

Using your code:

{% assign tag =  product.tags.first %} 
<a href="https://my-website/collections/{{tag}}">{{ collections[tag].title }}</a>

to fit my requirements doesn’t seem to be working:

{% assign tag =  product.tags.first %} 
<a href="https://my-website/collections/{{tag}}">{{ page[tag].content }}</a>


Sorry for the confusion! I’m not even sure if this is all possible...would be nice though!

0 Likes
Highlighted
Explorer
68 0 4

@Tejas_Nadpara 

 

Food for thought: on my product-card-list...the code below does not work, no error but nothing happens...so I'm thinking there has to be another way to output within an output.

Doesn't work (doesn't output content of page[ABC]:

{% assign tag = products.tags.first %}
{{ pages[tag].content }}

This does work (does output content of page ABC)

{{ pages.ABC.content }}
0 Likes
Highlighted
Shopify Partner
578 124 202

@tesstesting 

 

Okay, now can you please tell me what is the collection handle and page handle? so I get a better idea.

 

Thank you,

Tejas

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
0 Likes