jquery,html,liquid,business-catalyst
I have found a solution to the problem! You need to assign an array then split it. You need to create a variable first as it won't work if you try to split it within the for loop. {% assign array = ArrayTag | split: "," %} {% for i...
image,if-statement,shopify,liquid
product.variants is a collection, so you'll need to loop through it to determine if one of the variants has a title containing 'OS'. Something like this: {% assign contains_os = false %} {% for variant in product.variants %} {% if variant.title contains 'OS' %} {% assign contains_os = true %}...
Ok, the main issue was with the change function. I got it working like this: $(document).on("change",'#product-select-option-0', function() { var productquantity = $('#quantity').attr('value'); if (productquantity == 0) { $('#add-to-cart').prop('disabled', true); } }) Also changed = to == and .attr('max'); to .attr('value'); (as max is only supported in Internet Explorer 10, Opera,...
The for limit to the rescue ! {% assign posts = site.tags.Rails %} {% for post in posts limit:2 %} {{ post.title }} {% endfor %} ...
Let's say that your code snippets a re stored in /code folder as a.c, b.c and so on. Your page code.html can be like this one : {% for c in page.source %} {% capture filePath %}/code/{{c}}{% endcapture %} <a href="{{filePath}}">{{c}}</a> {% highlight c %} {% include_relative {{ filePath }}...
for-loop,variable-scope,shopify,liquid
The problem is you are outputting {{ has_y | plus: 1 }}, but not assigning anything to has_y inside the for loop. Try this: {% assign has_y = 0 %} {% for x in collections %} {% if x contains y %} {% assign has_y = has_y | plus: 1...
Unfortunately, Liquid has a poor implementation of boolean algebra. Using Liquid's operators and tags, here is a dirty way to achieve it: {% if include.featured == true and product.featured == true %} {% assign test = true %} {% endif %} {% if include.featured == false and product.featured == false...
In your project posts add background and thumbnail variables myprojectpage.html --- front matter variables ... background: #ffffff thumbnail: images/myproject.jpg --- You can then use them in your loop : {% for post in site.categories['project'] %} <div class="project" style="background:{{post.background}};"> <h3 class="project__title">{{ post.title }}</h3> <img src="{{ site.baseurl }}/{{ post.thumbnail }}" alt="post.title"> <p...
In the expression site.collections[collection_name].docs, collection_name is treated like a variable by liquid. So, no collection is returned. Try to quote it to make it a string : site.collections['collection_name'].docs ...
It seems writing a plugin is straight forward. This is what I have come up with: module Jekyll class ExtLinkTag < Liquid::Tag @text = '' @link = '' def initialize(tag_name, markup, tokens) if markup =~ /(.+)(\s+(https?:\S+))/i @text = $1 @link = $3 end super end def render(context) output = super...
I would try something like this: {% for product in collections.drinks.products %} {% if forloop.last %} // Insert image... {% endif %} {% include 'snippet-product-item' with 'four' %} {% endfor %} ...
No. You cannot parse XML with Liquid. Doing so is like trying to run your car on dishwashing soap. You may get a sputter at first that makes you think it'll go, but in the end, your car will sit in the parking lot till you clean out the gasline...
I believe you can do this: {% assign resindex = site.posts | where: "category", "research", | where: "lang", "en" | sort: "title" %} {% for post in resindex limit:4 %} <div> <p><a href="{{ post.url }}">{{ post.title | truncate: 52 }}</a></p> </div> {% endfor %} Though I am fairly confused by...
Liquid doesn’t allow evaluating Ruby code as part of the templates, which includes accessing instance variables. You can set locals through a hash: render 'main/index', :locals => { :name => 'foo' } foo will then be available in the template....
ruby,shell,markdown,jekyll,liquid
Jekyll already has support for syntax highlighters called Pygments and Rouge. These are installed and Pygments is the default. The benefit of this compared to other JS implementations is that your syntax is highlighted at compile time, so when the end user sees it they see HTML + CSS. Without...
html,css,twitter-bootstrap,jekyll,liquid
instead of trying to add the class in your liquid, you should utilize the selectors available in CSS to apply your new rules to that element. Assuming your wrapping <ul> has an id sections: #sections li:first-of-type { /* your rules here */ color: 'red'; } ...
Make sure that you have nothing after you front matter --- --- NO NEW LINE HERE !! No space, no new line Sometimes text editor add a newline at the end of the file. You can get rid of that with : {% assign content = post.content | strip_newlines %}...
jekyll,liquid,jekyll-extensions
Only post's categories are used to populate site.categories array. In a page, the only way to access categories, from the front matter, is {% for category in page.categories %}. And to scope is restricted to the page itself. :-(...
Create a string containing the variable name, then use the square bracket notation to access the setting with that name. For example: {% capture var %}dropdown-{{ loop_index }}-select{% endcapture %} {% if settings[var] %} ...
markdown,jekyll,liquid,github-pages
Thanks to David Jacquel for putting me on the right path. It seems that an image is an inline element and that if Markdown detects an image that is not inside a block element such as <figure></figure>, <div></div> or other similar block elements then it will apply a <p></p> tag...
type-conversion,shopify,liquid
Using assign with a math filter is correct. See this thread on GitHub, and this blog post. Variables created through {% capture %} are strings. When using assign, either of these options should give you a number: {% assign var1 = var1 | plus: 0 %} {% assign var2 =...
You can do this using liquid. Here is a basic example of what you could do. You will probably want to adjust it for your own use. {% assign myurl = "/css/bootstrap.min.css" %} {% if myurl contains '://' %} {{myurl}} {% else %} {{ myurl | prepend: site.url }} {%...
You are using the wrong object. What you're actually looking for is order.shipping_price: {{ order.subtotal_price | times:1.21 | plus:order.shipping_price | money }} ...
You can try using something like this {% for i in (1..20) %} <div class="{% if forloop.index < 5 %} class1{% endif %}{% if forloop.index >=5 and forloop.index < 9 %} class2{% endif %}{% if forloop.index >=9 and forloop.index <13 %}class3{% endif %}">class{{ forloop.index }}</div> {% endfor %} ...
ruby,jekyll,liquid,github-pages
You can use the remove filter like this : {{ host | markdownify | remove: '<p>' | remove: '</p>' }} ...
This should be the correct syntax, the [] are important: {% assign multi = "shampoo" %} {% for product in collections[multi].products %} ## Display ## {% endfor %} ...
ruby-on-rails,postgresql,heroku,nokogiri,liquid
The true culprit ended up being Nokogiri, not Liquid. Nokogiri is used to parse and manipulate the HTML that will eventually go through Liquid. During Nokogiri's time with the HTML, however, it was confusing the encoding (particularly when using doc.replace), and thus screwing up the special characters. Relevant question and...
javascript,html,forms,shopify,liquid
First, I need the form to contain the value of the length of the link list. Something like this? <form> <input type="submit" value="Add..." id="submit-table" /> <input type="hidden" id="linklist-length" name="linklist-length" value="{{ linklists.link-list-1.links.size }}" /> ... </form> Then I need to pass that length value to this script (which is a...
Answer yes. 1 - Your page.year must be a string as hash indexes are strings. So in you front matter : year: '2015' 2 - Get speakers depending on page.year : {% for speaker_hash in site.data[{{page.year}}].speakers %} ...
Try this: {% assign paragraphs = settings.intro | newline_to_br | split: '<br />' %} {% for paragraph in paragraphs %}<p>{{ paragraph }}</p>{% endfor %} ...
No way to do this. Inside a layout, the only things you get from your pages, posts and collections are the content, site and page variables. A capture made in a page, post or collection is not bubbling up to the layout....
collections,tags,shopify,product,liquid
UPDATE If you want to display all collections after a certain collection, once you find that handle, just have it parse the rest of them after it finds the handle. Sorry my liquid is a little rusty so this is pseudo code. {{ liquidtempvar = 0 }} {% loop through...
A relative link like /folder/file.html is relative to a host, like http://host.tld. host + relative path = http://host.tld/folder/file.html. As Jekyll serve sets the host's root folder at file:///C:/somePath/_site/ this finally resolve to root folder + relative path = file:///C:/somePath/_site/folder/file.html and this is the right path. Here you're talking about the...
I can't explain why the code you posted doesn't work, but I managed to do what you want to do by using the following liquid: {% capture base_url %}{{page.url | replace:'index.html','' }}{%endcapture%} {{ base_url }} ...
I assume that your site.screencasts are derived from page or post and all have a date in front matter. Starting with an empty array helper in _config.yml emptyArray: [] Then : {% assign pagesArray = site.emptyArray %} {% for post in site.posts %} {% assign pagesArray = pagesArray | push:...
javascript,html,forms,shopping-cart,liquid
I want to know if the line below is needed in this script, and if so, what purpose it serves. Calling the jQuery .focus() method with no arguments sets focus to the specified element. That line is the first line inside the document ready handler. So its purpose is...
javascript,html,angularjs,forms,liquid
I would try creating a directive that watches the value attribute and updates ng-model on changes. .directive('value', function() { return { restrict: 'A', require: 'ngModel', link: function(scope, element, attr, ctrl) { attr.$observe('value', function(val) { ctrl.$setViewValue(val); } } } }) ...
this is what you can do : blog/index.html --- layout: default title: Blog - Jake Tarr --- <section class="blog-feed"> <div class="ribbon-container"> <div class="ribbon"> <div class="ribbon__content"> <h6>Blog</h6> </div> </div> </div> {% comment %}------ Template setup ------{% endcomment %} {% assign numberOfFeaturedPosts = 1 %} {% assign postsPerRow = 3 %} <!--...
Saving a path in a variable {% capture path %}{{ site.url }}{{ site.baseurl}}/savedfiles/{% endcapture %} you can now use this variable like this : <a href="{{ path }}foo.html">Link to foo</a> Getting file path from a file It is a little bit tricky. But here is a way : {% assign...
The subresource request for the tag data needs to happen once for each post, like so: {% for item in bpost.items %} ... {module_data resource="blogposts" version="v3" fields="objectId,tagId,objectType,siteId,tag,post" subresource="tags" resourceId="{{ item.id }}" skip="0" limit="10" order="objectType" collection="postTagData"} <ul> {% for tagMeta in postTagData.items -%} <li> <a href="/retreivepostsbytag.html?tagid={{ tagMeta.tag.id }}" >{{ tagMeta.tag.tagName }}</a>...
css,image,responsive-design,height,liquid
This might solve your problem. In this snippet I considered that you can assign 'vertical' and 'horizontal' class to your images as per the nature of image. If you don't know which image is going to be vertical and horizontal then you have to use a little js there to...
Your approach is correct, and very similar to what I would have suggested. Alternatively, you could use an if statement with 2 conditions: {% assign found_mukluk = false %} {% for item in cart.items %} {% for collection in item.product.collections %} {% if found_mukluk == false and collection.handle == "mukluks"...
{% assign has_myvalue = false %} {% for post in site.posts %} {% if post.myvalue == true %} {% assign has_myvalue = true %} {% endif %} {% endfor %} {% if has_myvalue %} Here's some output because a post had myvalue==true {% endif %} ...
I know that you can edit a link title on a normal link as follows: {{ 'Foo Bar' | link_to: 'http://www.foobar.com', 'Foo Bar Title Here' }} So it MAY stand to reason that you could try the following: {{ tag | capitalize | link_to_tag: tag, 'Title Here' }} No promises...
I would consider writing a plugin for Jekyll, something like this: WeeklyHighlights.rb module Jekyll class WeeklyHighlights < Generator safe true priority :high def week_id(time) # to handle turn of year properly return time.strftime('%Y-%W') end def generate(site) # hash (dict) to store highlights grouped by week number highlights_by_week = {} today...
html,shopify,liquid,templating
Try something like this: {% assign related_posts = "" %} {% for article in blogs.blog.articles %} {% if article.tags contains product.handle %} {% capture post %} <li><a href="{{ article.url }}"><p>{{ article.title }}</p></a></li> {% endcapture %} {% assign related_posts = related_posts | append:post %} {% endif %} {% endfor %} {%...
collections,shopify,product,liquid
You can use the global collections object to access collection info from any page. Here's an example from the Shopify documentation that iterates over products in the "frontpage" collection: {% for product in collections.frontpage.products %} {{ product.title }} {% endfor %} The liquid object collections contains a list of all...
I'm not sure if this is exactly what you're looking for, but if you need to do calculations on the numbers in the data, then you could try something like this: var data; $.get('data.txt', function(d){ data = d; }); Then split that data first, based on newlines: data = data.split(/\r?\n/);...
Try {% include_relative {{post.path}} %} ...
css,sass,shopify,liquid,compass
I managed to figure it out thanks to this: https://coderwall.com/p/5by4ww/compass-add-min-to-the-filename I just appended this to the end of the config.rb file: require 'fileutils' on_stylesheet_saved do |file| if File.exists?(file) filename = File.basename(file, File.extname(file)) File.rename(file, "assets" + "/" + filename + ".scss.liquid") end end ...
What you've got looks like it should work (assuming you replace 'test' with your shop's name), but I'd probably write the if statement like this: {% if product.vendor != shop.name %}{{ product.vendor }}{% endif %} {{ product.title }} This will work in both product.liquid and product-grid-item.liquid. (Just search for {{...
With Liquid you can do : {% assign pad = 4 %} {% assign padStr = '0' %} {% assign numbers = "1|12|123|1234" | split: "|" %} {% for number in numbers %} {% assign strLength = number | size %} {% assign padLength = pad | minus: strLength %}...
No, MyField can't be assigned to. In fact, it can't be accessed at all - only public instance methods and properties are accessible in DotLiquid. It depends how you "register" this view model with DotLiquid: If the view model inherits from DotLiquid's Drop class, then all public instance methods...
javascript,jquery,html,shopify,liquid
Funk Doc's suggestion of following this Shopify tutorial is what I would have recommended too. This gist (from the above tutorial) shows how to bind an event handler to the 'change' event on the sort-by dropdown, causing a sort to be triggered whenever the selected value in the dropodown changes:...
javascript,jquery,ajax,shopify,liquid
Not tested but should help you along. <script> $(document).ready(function () { function createCollection(collection_title){ $.ajax{ type: 'POST', url: '/admin/custom_collections.json', data: {"title":collection_title}, dataType: 'json', success: function(response) { console.log(response); collection_id = response.id; console.log(collection_id); }, error: function() { console.log(response); } }; return collection_id; } $("#submit-table").click(function(e) { e.preventDefault(); var collection_title = $("#new_collection_title").val(); var...
The default filter, whilst it is in master, has not yet been released in a gem (2.6.1 is the latest gem at time of writing). Liquid’s behaviour when seeing an unknown filter seems to be to ignore it and return the string unchanged without reporting an error. You could use...
I managed to achieve this by adding a custom filter via Jekyll's plugin system: # _plugins/shuffle.rb module Jekyll module ShuffleFilter def shuffle(array) array.shuffle end end end Liquid::Template.register_filter(Jekyll::ShuffleFilter) And using: {% assign shuffled_array = page.array | shuffle %} {% for i in shuffled_array %} <p>{{ i }}</p> {% endfor %} ...
There is no list of Shop accounts available to check against. The only check you could make against is the shop email address or the shop customer_email and that is kinda loser-ish. You're in tough on this one as Shopify does not yet provide any Shop accounts. Even the embedded...
Alternative solution (for example, if you're hosting your Jekyll site on your own server and not on GitHub Pages): You can set a value in the config file _config.yml like this: environment: prod Then, you can have another config file which overrides the same value, I'll call it config_dev.yml: environment:...
{% assign recent_leader = site.data.leaders[dedupped_leader] %} {{ recent_leader.name }} {{ recent_leader.bio }} If you do this in a markdown file, it will output code block (see kramdown documentation) If you don't want code block, do : no line break after a not indented line {% assign recent_leader = site.data.leaders[dedupped_leader] %}...
{% for item in search.results %} {% if item.product.vendor == 'thevendor' %} {% else %} {% include 'search-result' %} {% endif %} {% endfor %} This should work....
GitHub Pages uses Pygments as the default syntax highlighter and the Liquid tag that wraps your code generates a lot of additional markup in the resulting HTML to make the code look pretty. The back-tick and tilde Markdown notation simply wrap your code in <pre><code class="language-c"> tags. If you want...
_includes/post_by_tag.html {% assign posts = site.tags.[include.tag] %} {% for post in posts limit: include.number %} <p>{{ post.title }}</p> {% endfor %} using it {% include post_by_tag.html tag='Rails' number=3 %} Et hop !...
Take a look at my answer to this similar question. Try this: {% assign color_from_settings = 'collection_color_' | append:forloop.index %} ... {{ settings[color_from_settings] }} ...
Given you have a post file _posts/2015-05-28-post_one.md From inside this post you have : page.id = /2015/05/29/post_one page.dir = /2015/05/29 In order to extract post_one whe do : {% assign imgNameStart = page.id | remove: page.dir | remove: "/" %} We now generate the base path we search for :...
parsing,shopify,tokenize,liquid
Liquid is pretty limited when it comes to creating arrays. The common approach is to use the split string filter. In your case, it would look something like this: {% assign my_str = 'a:3,b:1,c:2,d:2,e:2,f:2' %} {% assign my_arr = my_str | split: ',' %} {% for pair_str in my_arr %}...
I moved all my posts to kb folder inside _posts and ended up using this code: <nav> {% if page.path contains '_posts/kb' %} <a href="/kb/"></a> {% elsif page.title != "Home" %} <a href="/"></a> {% endif %} </nav> ...
Refer to the Maths Modulo filter: http://docs.shopify.com/themes/liquid-basics/output#modulo {% assign value = collections.size | modulo:2 %} {% if value == 0 %} even {% else %} odd {% endif %} Or if you'd prefer a one liner: {{ collections.size | modulo:2 | plus:1 | pluralize:'even','odd' }} ...
javascript,jquery,css,shopify,liquid
$.ajax({ type: 'GET', url: 'http://your-store.myshopify.com/cart.json', dataType: 'jsonp', success: function(data) { var item_count = data['item_count']; //If there are items in cart if(item_count > 3) { $('#add-to-cart').hide(); } } }); Also if you see this (http://docs.shopify.com/support/your-website/themes/can-i-use-ajax-api) Ajax API you can make a call to GET /cart.js and you will get item_count in...
No, the module_json tag does not support accessing external JSON data. When attempting to use it in that way, it will only render: <!-- No input data found --> ...
collections,filtering,shopify,liquid
The reason you're getting theme-none is because your if statement checks if the collection's handle is 'clothing', 'pictures', etc. but you've set the collection to collections.all so it's never going to match any of those conditions. What you want to do instead is check if the current product is within...
ruby,for-loop,yaml,jekyll,liquid
I got this working by updating the data model and creating a nested loop: --- chapters: - title: "CHAPTER 1: LEADERSHIP" chapterList: - Lorem ipsum dolor sit amet, consectetuer adipiscing elit. - Aliquam tincidunt mauris eu risus. - Vestibulum auctor dapibus neque. - title: "CHAPTER 2: THE EXPERIENCE" chapterList: -...
This is because post.excerpt is already wrapped in p tag. If you want to output excerpt with no p tag, you can do {{ post.excerpt | remove: '<p>' | remove: '</p>' }}. See Jekyll documentation....
Try this : {% capture fullpath %}{{ site.url }}{{ page.url}}{% endcapture %} {% if comment.path == fullpath %} ...
It is simple. Every customer has an ID unique to them. So name your customer's collection after their ID. Put whatever you want in there. When they visit the store and that collection, use Liquid to ensure they are logged in, and that the current customer's ID matches the handle...
html5,for-loop,navigation,jekyll,liquid
You're comparing two counter that are not working the same way. {% assign imgIndex = {{forloop.index0}} This will count from 0 to array.size-1 {% assign naviIndex = {{forloop.index}} This will count from 1 to array.size As your not in the same "time zone", for the first image you have imgIndex...
html,tags,jekyll,shopify,liquid
{{ content }} refers to all the content that in the file that is being converted to HTML code. For example, if you are passing a blog post on 'What is Jekyll' to any layout that has the {{ content }} tag, all text other than the YAML front matter...
Firstly print your 'product' array and check what it will return to you while checking for other one.
You cannot do this. Include files are rendered server side and you cannot touch that pipeline. Instead, do the more obvious thing and render your snippet HTML in a container that is hidden. Use Javascript to unhide the container when you are ready, for example 1000ms after the page assets...
ruby-on-rails,parsing,date,liquid
19880808 is date in Unix format. i.e. this is not 1988-08-08, this is 1970-08-18 (or 19 in +3 timezone). $ ~ irb 2.1.0 :001 > Time.at(19880808) => 1970-08-19 05:26:48 +0300 If you want to show 19880808 as 1988-08-08 you should parse in before use Date#strptime method and after that convert...
On collection page, fetch all the collections. If your current collection handle is t-shirt and your sub collection handle is linen-t-shirt. Check for all the collections which contains current collection handle, then show the details. {% assign currentCol = collection.handle %} {% for collection in collections %} {% if collection.handle...
There's currently an issue with the description field and fields of type Image - they aren't made available for use unless there is some Liquid markup in the standard list template file (at /Layouts/Webapps/WEBAPPNAME/list.html). Adding a comment such as this should resolve it: {% comment %} This is to get...
svg,jekyll,liquid,jekyll-extensions
{% capture svg %}{% include img/gnu.svg %}{% endcapture %} {% assign svgsplit = svg | split: 'svg11.dtd">' %} {% assign svgpart = svgsplit[1] | escape %} {{ svgpart }} I think this does it....
jquery,ruby,shopify,liquid,jcarousel
Looks like each slide already has a button with a link that is set in Settings: <a class="btn btn-lg btn-default" href="{{ settings[link] | escape }}" role="button">{{ settings[link_text] | escape }}</a> If you're not already using this functionality for something else, you could modify this code to add the link to...