How to exceed 255 characters limit of product tag in Shopify? - tags

I am looking for a way to exceed the 255 characters limit on product tag in Shopify admin. Please suggest any way of doing so.

In general this does not sound like a good idea. If you are trying to embed extra information per item you might want to look at putting that in a snippet file and then formatting your tag like __extra File1 and then a snippet like the following in your product template:
{% for tag in product.tags %}
{%if tag contains '__extra' %}
{% assign snip = tag | remove_first : '__extra ' %}
{% include snip %}
{% endif %}
{% endfor %}
This would allow you to share large chunks of information per product while not blowing up your tags.
If you adopt this approach then you'll also want to go through your theme and make sure you filter out tags beginning with '__'. e.g.
{% for tag in collection.all_tags %}
{% assign tag_pref = tag | slice:0,2 %}
{% unless tag_pref == '__' %}
... do your tag related layout
{% endunless %}
{% endfor %}

Related

Adding attributes to Shopify's {% form %} liquid tag

Is it possible to add attributes to Shopify's {% form %} liquid tag? I want to give all my forms id's so that I don't have to rely on parent elements to target their styles.
Yes you can add attributes.
Example:
{% form 'contact', id: "test" %}

How do I display a specific post in Jekyll?

I'm wanting to use Jekyll as a CMS essentially, so I would like to take the content from a post and display it in a specific area of my website.
{% for post in site.posts %}
{{ post.content }}
{% endfor %}
This displays all of the content from all of the posts, however I'd like to take content from one post at a time. I'm fairly new to Jekyll, so I'm not sure if i'm supposed to add YAML front matter into my posts and target them with a "for post in site with title_____" post.content" of sorts.
Thank you!!
{% assign thepost = site.posts | where:"slug","post_slug" %}
{% for post in thepost %}
{{ post.content }}
{% endfor %}
And on the post;
slug: post_slug
I figured it out, sorry I posted prematurely.
The answer is add a category to your post with YAML front matter and then in your include file use:
{% for post in site.categories.CATEGORYNAMEHERE %}
{{ post.content }}
{% endfor %}

Customize form_row for different form types

I want to set different form_row layout for different form type. I found in templates block named "choice_widget_collapsed", but it render only select tag with options.
I cannot find where this block is being used. Actually it seems that it is rendered instead of form_widget block. I suppose there is somewhere switch/if structure which checks form type and renders appropriate block, but i dont know where to find this switch, or dont know how to check input type inside form_row block.
I know that block type can be found inside form.vars.block_prefixes array, but this sux, because its position may change in the future as it was already.
So the question is: how can i make form_row display different thing depending on form field type?
You should override the normal block in a theme of yours. This block should work like this:
{% block form_appropriate_block %}
{% spaceless %}
{% if form.vars.widget = 'myIntendedWidgetType' %}
[yourTemplate]
{% else %}
{{ parent() }}
{% endif %}
{% endspaceless %}
{% endblock form_appropriate_block %}
And then, in your template, activate your theme using:
{% form_theme form 'MyBundle:Form:formTheme.html.twig' %}
In this way, your form theme is used only when needed, and if the type is not the one you want, it falls back to the normal behaviour.

Shopify Liquid - if product.template contains

I am trying to retrieve the template for a specific product while NOT on the product template page. I am on the collection page and am trying to adjust the Quick shop feature to only show the add to cart for products no associated with a custom template. For example, I've assigned a 'consultation' template to a group of products. However because I am no longer on the product template page, the Quick shop doesn't recognize the consultation product. Any ideas on how I can make this work other than using tags, types and collections?
Thank you!!
On collection page , products for that collection are called in a loop, something like
{% for product in collection.products %}
...
{% assign prodtemplate = product.template_suffix %}
{% if prodtemplate contains 'consultation' %}
{% else %}
//Add to Cart code
{% endif %}
...
{% endfor %}

How do you setup one or more different form_row templates in Symfony 2?

I have a project in Symfony2 where I have lots of different forms that do lots of different things and one thing I am struggling with at the moment is working out how I can set two different templates to handle form_rows.
I have specified one form_row template in a fiels.html.twig file that handles form rows as follows:
{% block form_row %}
{% spaceless %}
<div class="form-element{% if errors %} form-element-error{% endif %} widget-group clearfix">
<div class="widget widget-1-of-3">
{{ form_label(form) }}
</div>
<div class="widget widget-2-of-3">
{{ form_widget(form) }}
{% if errors %}
<small>{{ form_errors(form) }}</small>
{% else %}
{% if help is defined %}
<small>{{ help }}</small>
{% endif %}
{% endif %}
</div>
</div>
{% endspaceless %}
{% endblock form_row %}
This works great for me for general forms, but I also have a number of form elements that I have in tables as well. This is generally for groups of form data that I am updating.
In this case I then want to be able to specify using a different form_rows template.
I understand that I could specify the row via the field name or group, but I have a lot and I just want a more general way of doing this.
Does anyone know how this could be achieved.
You can have a lot of form themes defined in different templates.
Just add in your twig file on the top where you want to use theme:
{% form_theme form 'AcmeDemoBundle:Form:fields.html.twig' %}
{{ form_widget(form) }}
where form_theme file can be any twig file with theme definition.
Now form widget is decorated with attached theme.