Limit number of tags in content - pelican

there is that old blog post to get a list of categories and tags from the content.
I only found tag_cloud as the only plugin dealing with tags no further mention in the documentation
Is there any way to limit the usable tags e.g. through the configs ?

One option is you can define a ALLOWED_TAGS variable in pelicanconf.py to contain the tags that you want to allow, then in places where tags are placed you can add a JINJA if block to allow only these tags
#pelicanconf.py
...
ALLOWED TAGS = ("tag1", "tag2", "tag3", tag4")
Example of generating tags for an article below
<div class="article-tags">
{% for tag in article.tags %}
{% if tag in ALLOWED_TAGS %}
<{{tag}}</span>
{% endif %}
{% endfor %}
</div>

Related

Shopify List Blog Tags

I'm trying to create a page in Shopify that loops through all the tags assigned to blog articles in a blog called 'Recipes', and simply list them all.
This seems simple, but my page is not outputting any tags.
-I have a blog created called 'Recipes'
-I have blog posts assigned to the 'Recipes' blog, and each one has a different tag assigned.
-I created a template (page.blogtags.liquid), and assigned that template to a page called 'Blog Tags'
My code for page.blogtags.liquid is as follows:
<div id=”blog-tags”>
<!– Loops over all the tags used in Recipes blog –>
{% for tag in blogs[recipes].tags %}
<h2>{{ tag }}</h2>
{% endfor %}
</div>
The page is outputting the div, but it contains nothing.
What am I doing wrong?
You are just missing quotes around recipes. Currently, Liquid is treating recipes as a variable and since it is undefined, it silently fails. All you needs is 'recipes' or "recipes" to specify that you want to access blogs property named recipes. So the code would become
<div id=”blog-tags”>
<!– Loops over all the tags used in Recipes blog –>
{% for tag in blogs['recipes'].tags %}
<h2>{{ tag }}</h2>
{% endfor %}
</div>
Alternatively, you can also do blogs.recipes.tags
<div id=”blog-tags”>
<!– Loops over all the tags used in Recipes blog –>
{% for tag in blogs.recipes.tags %}
<h2>{{ tag }}</h2>
{% endfor %}
</div>

Accentuate Custom Fields | Get blog posts by reference handle

I have a new site I'm setting up whereby blog posts contain related products and the products contain related blog posts. I can make this happen easily enough by adding product references on blog articles and blog references on products.
My main issue with this approach is that the client will need to do double entry. What I'd like to do is simply add a product reference to the blog posts and then on the product page, loop all blog posts and display any that have a reference to the current product handle.
I have a variation of this working to some extent:
{% assign related_posts = "" %}
{% for article in blogs.news.articles %}
{% if blog.metafields.blog_info.linked_products contains product.handle %}
{% capture post %}
<li><p>{{ article.title }}</p></li>
{% endcapture %}
{% assign related_posts = related_posts | append:post %}
{% endif %}
{% endfor %}
{% if related_posts.size > 0 %}
<ul> {{ related_posts }} </ul>
{% else %}
No related posts!
{% endif %}
However I have 2 problems:
1.) Shopify limit the return of blogs to 50 articles, so it isn't searching all posts
2.) If it did work on all posts, would this significantly slow down the page?
Does anybody know how to access all blog articles in one go, or have a better idea for how to implement this functionality?

Get all shopify products filtered by a Tag using Liquid

Is it possible to query all products in shopify by a tag (or set of tags) using Liquid.
I thought I had it by looping through collections.all.products and then filtering in the loop but then realised that the collection was limited to a page size of 50.
If it meant to be displayed in frontend, Shopify does not support the paginate hack quoted by Hymnz above.
However, even if query is limited to 50 products, you may clearly make your query and then use pagination.Something like this may work to filter products list:
{% for product in collections.all.products %}
{% if product.tags contains 'mytag' %}
Do something
{% endif %}
{% endfor %}

Multiple linklists on shopify categories (sidebar)

Yet another shopify question. I have a sidebar on shop/collections page
settings.sidebar_categoryblock_linklist
Which shows links to my main collecions: men/woman/kinds ect.
Yet I have another collection list based on product tags:
Winter/Autumn/Casual/Business etc
How do I get to display them on the sidebar? Meaning how can I put several linklists as categories link lists?
Thanks in advance
Julia
In a collection page, you have access to all the tags (unique) that the products have. You can use these tags to see if the belong to any collection and then display them. The code is as follows:
{% for tag in collection.all_tags %}
{% assign c_collection = collections[tag] %} // c_collection is used so the current display page's collection doesn't get disturbed
{% if c_collection.title != '' %}
{{ tag | link_to: c_collection.url,c_collection.title }} // not sure about this, but you can use proper html as well here
{% endif %}
{% endfor %}

Shopify: List ONLY active tag

I imagine someone has created this solution before and for the life of me I can't make sense of it.
I am using the following code to create a list of tags for my Men's T-Shirt department:
<ul>
<li class="clearfix filter-type">Garment Type</li>
{% assign tags = 'Short Sleeve, Long Sleeve, Polo, Crew %}
{% for tag in tags %}
{% if current_tags contains tag %}
<li class="selected">{{ '-' | link_to_remove_tag: tag }} {{ tag }}</li>
{% elsif collection.all_tags contains tag %}
<li>{{ tag | link_to_add_tag: tag }}</li>
{% endif %}
{% endfor %}
</ul>
It works as expected, but what I am trying to accomplish is if one of the tags is selected, say "Short Sleeve", then the list should display ONLY "- Short Sleeve" and nothing else. Not allowing the customer to select any other tags from that group. Simply because, if something is tagged "Short Sleeve" it is not "Long Sleeve"
As it is working now, the customer could select "Short Sleeve" and then select "Long Sleeve" resulting in no results.
Any guidance would be greatly appreciated, thanks!
The Filters page on the Shopify wiki states:
link_to_add_tag Links to products that have the given tag and any previously applied tags
link_to_tag Creates a link to the tag page
So, simply change link_to_add_tag to link_to_tag.
Also see:
Managing Subcategories using Tags. This article uses link_to_tag to filter products by colour.
Related discussion on Shopify forum, Only one Tag at a time.