In Trac 0.12, one has the ability to change the contents of email notifications and I am trying to simplify the template to only include the changes, like
{% choose ticket.new %}\
{% when True %}\
$ticket_body_hdr
$ticket_props
$ticket.description
{% end %}\
{% otherwise %}\
{% if changes_body %}\
${_('Changes (by %(author)s):', author=change.author)}
$changes_body
{% end %}\
{% if changes_descr %}\
{% if not changes_body and not change.comment and change.author %}\
${_('Description changed by %(author)s:', author=change.author)}
{% end %}\
$changes_descr
--
{% end %}\
{% if change.comment %}\
${changes_body and _('Comment:') or _('Comment (by %(author)s):', author=change.author)}
$change.comment
{% end %}\
{% end %}\
{% end %}\
--
${_('Ticket URL: <%(link)s>', link=ticket.link)}
But where do I find a reference for the language that the template written in? And how to I put in a comment that can hold a revision-control expansion like $Id$?
Trac uses Genshi for templates in two different forms: XML and text.
I've never used TracNotification, but what you post is a text template. Documentation for it can be found at the Genshi wiki.
Related
Objective:
I want to render a Shopify section inside of a template using a variable as the section file's name. i.e.
Example
Template: templates/parent.liquid
Section: sections/child.liquid
Attempting to render (include) child.liquid inside parent.liquid when variableName = 'child'
context: *child* could be anything -- in my theme's specific use case, I'm assigning variableName = page.handle. If page.handle matches an existing product vendor AND sections/[page.handle].liquid exists, I am includuing it in the page.
WHY? I want to avoid a hardcoded list of available section-files in lieu if this proposed progammatic approach of dynamic filenames derived from the current page.
The following code would go inside templates/parent.liquid
this works (hardcoded quoted strings):
BUT, I want to avoid hard-coded filenames at all costs.
{% section 'child' %}
these all throw an error (any form of dynamic filename):
{% section variableName %}
{% section {{ variableName }} %}
{% section 'variableName' %}
{% section "'" + variableName + "'" %}
{% section variableName %}
{% section "{{ variableName }}" %}
{% section [variableName] %}
edit more errors
{% render variableName %} Syntax error in tag 'render' - Template name must be a quoted string
{% include variableName %} look for a snippet, not a section
{% include sections.variableName %} Liquid error: Argument error in tag 'include' - Illegal template name
{% include sections.[variableName] %} Liquid error: Argument error in tag 'include' - Illegal template name
Research
The closest article I've found via Google is https://community.shopify.com/c/Shopify-Design/Dynamic-Liquid-Variable-inside-Liquid-tag/td-p/162451
Pseudo Answer
I'm searching for a working solution along the lines of:
{% include sections.[page.handle] %}
Use include or render
passing variable to section is not possible
Question asked here
Document
Variables created outside sections are not available within sections.
Likewise, variables created in sections are not available outside
sections. If a section includes a snippet, the snippet has access to
the variables in the section.
using variable as a filename will not work for render. It only works for include
For Example
{% assign fileName = "product-" | append: product.handle %}
{% capture productLinkContent %}
{% include fileName %}
{% endcapture %}
{% unless productLinkContent contains "Liquid error: Could not find asset " %}
{% include fileName %}
{% else %}
do something else
{% endunless %}
so, In your template/parent.liquid call {% section 'parent-template' %}
and in parent-template.liquid use include like above.
The reason is that you need to make sure that the section files exist so that it does not break shopify customizer, and there is no way to check that using liquid code right now.
Here is another solution if you really want to stick with the variable solution, is that you pass the file with if-else / case - when statement;
{% assign fileName = "product-" | append: product.handle %}
{% case fileName %}
{% when 'product-a' %}
{% section 'product-a' %}
{% when 'product-b' %}
{% section 'product-b' %}
{% else %}
do something else
{% endcase %}
I have create many collections like All Products, New Releases, T-Shirts, Pants etc. And I have two categories of products like Men's and Women's. Some collections specifically for Men's and some collections specifically for Women's. I create two tags Men's and Women's. I create menu by collections query by tags. My my products collection url is like this:
/collections/all-products/mens
/collections/all-products/womens
/collections/new-releases/mens
/collections/new-releases/womens
/collections/bras/womens
I want to show some text and menu list when collection.url show /mens or /womens.
{% if collection.url contains mens %}
do something
{% endif %
Above condition not working. I know why not working because {{ collection.url }} provide /collections/all-products. {{ page.url }} will not work for collection object. I haven't find any suggestion or liquid code reference where show men's or women's products in collections page it will show specific text.
If use in loop it will work.
{% for product in collection.products %}
{% for tag in product.tags %}
{% if tag contains 'mens' %}
<h3>Mens Products</h3>
{% endif %}
{% endfor %}
{% endfor %}
Above code will not work for me because it's inside loop. I need to show outside of loop. I don't understand how to achieve it. here is the reference site. Below have image how I want.
Need help!
You have access to the current_tags, refer to docs: https://shopify.dev/docs/themes/liquid/reference/objects/current-tags
This will return an array of all the tags you are viewing at the moment (in case you are viewing more than one tag).
So your check will be:
{% if current_tags contains 'mens' %}
do something
{% endif %}
That's pretty much the just of it.
I really like how the menu is coming along! Here are some ideas you could consider for your category specific menu, if you've not gotten where you want yet.
For your url strategy, what you're looking for is handle. Handles are specific to liquid. https://shopify.dev/docs/themes/liquid/reference/basics/handle
You could make a custom collection template if those 2 categories need to be fairly different: https://shopify.dev/tutorials/customize-theme-create-alternate-templates. If you do that, then you can use template_prefix from the collection object.
Assign a variable outside your loop and then set it inside the loop like:
{% assign is_mens = false %}
{% for tag in product.tags %}
{% if tag contains 'mens' %}
{% assign is_mens = true %}
{% endif %}
{% endfor %}
then {% if is_mens %} or {% unless is_mens %} for your dynamic content, or a case statement to define content specific to categories in your menu.
Hope this helps!
What's the opposite of contains in Shopify Liquid Smarty tags?
I basically want to hide products from Search page that has the tag hideme
Example code : {% if product.tags contains 'hideme' %}. In this I want to use does not contain instead of contains
The opposite of {% if %} is {% unless %} so your code would change to:
{% unless product.tags contains 'hideme' %}
<blinky> stuff mmm good for cookie monster </blinky>
{% endunless %}
How can I check if the current page is the cart page in theme.liquid? I tried page.handle=='cart' but it is not working.
You don't need the handle filter, you can just use:
{% if template == 'cart' %}
...
{% endif %}
Neither answer is absolutely correct, including the accepted one.
The cart template as others may have alternates e.g. cart.fancy.liquid which can be accessed via /cart?view=fancy. In that case, the equality operator will not work as expected as template variable will be equal to cart.fancy.
The contains operator is not the best option as well, as it will also be TRUE for product.cartridge.liquid and similar templates.
Based on the above here's the better solution to use in your themes:
{%- assign templateBase = template | slice: 0, 4 -%}
{%- if templateBase == 'cart' -%}
...
{%- endif -%}
It will be TRUE for cart template and all its alternate views.
It will be FALSE for any non-cart templates that may contain
cart sequence in their suffixes i.e. alternate views.
This is another option:
{% if request.path == routes.cart_url %}
We are on the cart page.
{% else %}
We are on some other page.
{% endif %}
I found a solution for this.
using {{template|handle}}
so my code is
{% capture template_handle %}{{ template | handle }}{% endcapture %}
{% if template_handle == 'cart' %}
{% endif %}
Also we can check using:
{% if template contains 'cart' %}
...
{% endif %}
I'm trying to retrieve all Shopify collections for our store which have products matching tag dog.
{% for collection in collections %}
{% assign gato = 'false' %}
{% assign perro = 'false' %}
{% for tag in collection.tags %}
{% if tag == 'Cat' %}
{% assign cat = 'true' %}
{% elsif tag == 'Dog' %}
{% assign dog = 'true' %}
{% endif %}
{% endfor %}
{% if dog == 'true' and cat == 'false' %}
<li>{{ collection.title | link_to: collection.url }}</li>
{% endif %}
{% endfor %}
I successfully get this list when I'm at homepage (telepienso.com). (See footer screenshot: A). I have the same exact code in collection.liquid and I get some of the collections but NOT all of them. (telepienso.com/collections/all). (See list on the right screenshot: B). Is there any restriction inside collection.liquid which can affect?
A screenshot (productos para perros list):
B screenshot (sección perros list):
This was the cause of the problem. The collections variable was being paginated.
By moving the code in the question outside of the paginate liquid tag, all collections are displayed in the sidebar (the same as the footer).
EDIT: The above link is broken because the question was deleted due to low traffic. I've copied the content from the question below for reference.
Shopify - issue accessing the collections global variable inside paginate
I would like to be able to access the collections global variable from within a paginated group of products, but the collections variable is also paginated if it is accessed within a paginate liquid tag.
For example (in collection.liquid):
{% for collection in collections %}
{{ collection.title }}
{% endfor %}
<br />
{% paginate collection.products by 4 %}
{% for collection in collections %}
{{ collection.title }}
{% endfor %}
...
{% endpaginate %}
Output:
All Collection1 Collection2 Collection3 Collection4 Collection5 Collection6 Frontpage
All Collection1 Collection2 Collection3
The for loop before the paginate tag lists all collections as you would expect, but doing the same thing within the paginate tag causes collections to be paginated as well as the products I am actually wanting to paginate.
Is there a way to access the collections global variable within a paginated group of products without it also being affected by the pagination?
Why would I want to do this? It was causing this problem, and was not immediately obvious because the code using the collections variable was in a separate snippet to the code with the pagination.
EDIT 2: I can no longer reproduce this issue, it appears to have been fixed.