Listing page with dynamic tag

Hello,

I have a page with a description of one machinery, main content is the description, after this I have two section, first with features and second with optionals. These sections are cards dynamically created picking infos from page with particular tags. For example, the cards of feature, are chosen from pages with tag ‘features’ and ‘model_name’… all works, but I need the tag ‘model_name’ will be dynamic, will be the same tag used for model page.

How I can do this? Thanks for any suggestions…

Hi,
Are you still looking for the solution? It will be easier to help you if you post the code you’ve already got.

Hi, thanks for suggestion!

this is the section in product page with “features” tagged items:

   <div class="p-4">
    	<div class="owl-carousel owl-theme">
    	{% for post in taxonomy.findTaxonomy({'category':'features','tag':'thisproductmodel'}).order('date', 'desc') %}
    	<div>
    	{% set image = post.media.images|first %}
    		{% if image %}
    		<img src="{{ image.url }}" class="img-responsive img-fit-cover">
    		{% endif %}
    	<blockquote>
    		<p class="text-justify">{{ post.content }}</p>
    		<cite>{{ post.title }}</cite>
    	</blockquote>
    	</div>
    	{% endfor %}	            
    	</div>
 </div>

at the end of page, I use this:

<div id="tags">
	<div class="container grid-xl vertical-padding">
		<hr>
		<p class="text-gray text-right">Categories: 
		{% for tag in page.taxonomy.tag %}
		    <a class="chip" href="search/tag:{{ tag }}">{{ tag }}</a>
		{% endfor %}
		</p>
	</div>
</div>

and I need the tag used for this last section (the tag identify this product), will be used automatically in features section.

To be more precise, in Taxonomies, the page have one categories productcategory and two tag, brandname and productmodel

Thanks

Not tested, but you can do something like that:

{% for post in taxonomy.findTaxonomy({'category':'features','tag':page.taxonomy.tag|first}).order('date', 'desc') %}

This will use the first tag as product model for this machinery. The problem is taht this solution assume that the product model is always the first tag. You can of course choose to use the last tag, or any other tag, but this solution will constrain you to always define your tags in the same order. This seems quite error-prone.

Better, I suggest to create custom taxonomies instead of using the tags. As explained here put something like this in your site.yaml:

taxonomies: [category,tag,brandname,productmodel]

Then,

  • in your machinery page:
---
taxonomy:
    productmodel: "Toaster XYZ"
    brandname: "Some brand"
---
  • in your feature pages:
---
taxonomy:
    category: features
    productmodel: "Toaster XYZ"
---
  • in the template:
{% for post in taxonomy.findTaxonomy({'category':'features','productmodel':page.taxonomy.productmodel}).order('date', 'desc') %}

Another solution, among others, may be:

  • in site.yaml:
taxonomies: [category,tag,feature_for]
  • in your machinery page:
---
title: "Toaster XYZ"
---
  • in your feature pages:
---
taxonomy:
    feature_for: "Toaster XYZ"
---
  • in the template:
{% for post in taxonomy.findTaxonomy({'feature_for':page.title}).order('date', 'desc') %}

Many thanks lilive!

I added two taxnomies, “brand” and “model”, as result now I have:

{% for post in taxonomy.findTaxonomy({'category':'features','model':page.taxonomy.model}).order('date', 'desc') %}

An everything works perfect!

:+1: