Global Liquid Filters - CrystalCommerce Liquid Documentation for Designers

Global Liquid Filters

The following filters are available in every liquid template.

Filters Supported

protect_against_forgery?

Always returns false

asset_url(filename)

Returns asset path relative to the current theme’s asset dir on the cdn.

Example: {{ "foo.png" | asset_url }} results in: “http://cdn2.crystalcommerce.com/themes/clients/TerraBlue/assets/foo.png”.

cdn_url(filepath)

Returns the url on the cdn for the path specified

Example: {{ "/cats/foo.png" | cdn_url }} results in: “http://cdn2.crystalcommerce.com/cats/foo.png”.

link_to(text, url)

Given the link text and the url, produces an HTML link. Example: “Foo” | link_to: “foo.com” results in: ”<a href=’foo.com’>Foo</a>”.

css_minify_tag(name, debug=false)

Returns the stylesheet tag linking to the given css minification as defined in the themes config

Has optional second argument, if set to true will just output the css files as separate stylesheet links, use for debugging.

Example: {{ "foo" | css_minify_tag }}

js_minify_tag(name)

Returns the script tag linking to the given js minification as defined in the themes config

Example: {{ "foo" | js_minify_tag }}

money(amount, unit = ’$’)

Formats the given amount if it is present and not already formatted. If it isn’t present, returns N/A. The unit defaults to the locale unit (specified by the theme). Examples:

{{ "" | money }} results in: “N/A”

{{ "$3.50" | money }} results in: “$3.50”.

{{ 3\.50 | money }} results in: “$3.50”.

{{ 3\.50 | money: € }} results in: “€3.50”.

category_photo_link(cat)

Produces a photo link for the given Category Drop.

photo_link(obj, size = ‘thumb’, img_opts = {})

Produces a photo link for a generic drop. The drop must have photo and url properties.

photo_url(photo, size = ‘thumb’)

Returns a photo url given a Photo Drop. If the photo is null, returns the anchor link “#no-photo-url”. Sizes are thumb, medium, large, huge

icon(name, options = {})

Returns an image tag for the given icon name. Options can take the keys size, alt, class, shadow (true/false).

descriptor_value(item, descriptor)

Given a descriptor and a variant, returns the value the variant represents.

Example: variant_drop | descriptor_value: descriptor_drop results in “English” given a Language variant descriptor.

descriptor_value_by_name(item, name)

Given a descriptor name and a variant, returns the value the variant represents,

Example: variant_drop | descriptor_value_by_name: "Language" results in “English”.

link_to_add_buy_order(text, product)

Creates a button which adds a qty of the product with the given text and Product Drop in an AJAXy fashion.

link_to_add_buylist(text, product)

See link_to_add_buy_order.

link_to_mass_add_to_cart(text)

Creates an AJAX button that takes all the quantities in the catalog form and submits them, adding them to the cart.

link_to_add_cart_with_qty(text, product, variant = nil)

Creates an add to cart linki and accompanying text field tag for the qty to add.

link_to_add_cart(text, product, variant = nil)

Creates a link to add the given product and optional variant to the cart via AJAX.

increment(number, amount = 1)

Increments the given number by the given amount. Seriously.

link_to_add_wishlist(text, product, variant = nil)

Creates a button that adds the given product/optional variant to the user’s wishlist via AJAX.

link_to_delete_address(text, address)

Creates a link to delete an address given an Address Drop.

link_to_edit_address(text, address)

Creates a link to edit an address given an Address Drop.

link_to_delete_card(text, card)

Deprecated

link_to_edit_card(text, card)

Deprecated

link_to_delete_wishlist_product(text, product)

Creates a link to delete the given product from the user’s wishlist.

link_to_delete_payment(text, payment)

Creates a link to delete the given payment for the user given a Payment Drop.

link_to_delete_coupon(text, coupon)

Creates a link to delete the given coupon for the user given a Coupon Drop.

ajax_request_tag(text, url)

Generic ajax POST builder. Generates an ajax link which posts to the given url.

nl2br(text)

Converts newlines to <br /> tags.

country_options(selected = nil)

Creates option tags for a select tag to choose a country. The selected argument should be the 2-letter country code, like “US”.

image_tag(url, options = nil)

Creates an image tag from the given url. Options seem to be ignored. Seriously.

checkout_address_selector(address, cart)

Deprecated.

checkout_shipping_method_selector(method, cart)

Deprecated.

checkout_credit_card_selector(card)

Deprecated.

checkout_credit_card_exp_month(id)

Deprecated.

checkout_credit_card_exp_year(id)

Deprecated.

icon_url(name, size = 32, type = ‘shadow’)

Returns a relative path to the icon given the name of it. Example: “check” | icon_url: 16 results in: “/images/icons/16x16/shadow/check.png”

paginate(products)

Generates a paginator for the given list of products.

start_paypal_checkout_form(order, id = “paypal_checkout_form”)

Deprecated

google_analytics_form(order)

Creates a form for google analytics given an Order Drop.

survey_question_input(question)

Generates a survey question input given an Question Drop.

category_paginated_url(category, page)

Genrates a url for category browsing given a Category Drop and Pagination Drop.

search_category_dropdown(default_category_id)

Dropdown category select form field for limiting a site search by first-level category. Will have selected the current searched for category.

Example:

<select id="search_category_select" name="c">
  <option value="1" selected="selected">All Categories</option> 
  <option value="24">Magic Singles</option>
</select>
search_query_box(placeholder_text = ””)
Input form field of type search for the site query. Will have the value of the current search.
Example:
<input id="q" name="q" type="search" placeholder="Search for..." value="whatever" />