Comments (6)
Worth noting that cache=false
will no longer work.
from shopify-code-snippets.
@mrpassiontea You can use the following as an alternative:
{{ 'tag' | link_to_add_tag: 'tag' | split: 'href="' | last | split: '"' | first | split: '?' | last | replace: '&', '&' }}
Bare in mind that this limits the param names you can use, I don't have a full list but I've found the following works:
- q
- key
- id
- collection
- attributes
- comment
- note
- tag
- type
- token
Hope this helps!
That's some impressive filter chaining π Given the lack of regex in liquid, that's a clever way to extract the URL from an anchor tag. Nice work!
from shopify-code-snippets.
@mrpassiontea You can use the following as an alternative:
{{ 'tag' | link_to_add_tag: 'tag' | split: 'href="' | last | split: '"' | first | split: '?' | last | replace: '&', '&' }}
Bare in mind that this limits the param names you can use, I don't have a full list but I've found the following works:
- q
- key
- id
- collection
- attributes
- comment
- note
- tag
- type
- token
Hope this helps!
from shopify-code-snippets.
@mrpassiontea You can use the following as an alternative:
{{ 'tag' | link_to_add_tag: 'tag' | split: 'href="' | last | split: '"' | first | split: '?' | last | replace: '&', '&' }}
Bare in mind that this limits the param names you can use, I don't have a full list but I've found the following works:
- q
- key
- id
- collection
- attributes
- comment
- note
- tag
- type
- token
Hope this helps!
That's some impressive filter chaining π Given the lack of regex in liquid, that's a clever way to extract the URL from an anchor tag. Nice work!
Here is the snippet using this method
{% capture pageUrl %}{{ "tag" | link_to_add_tag: "tag" | split: 'href="' | last | split: '"' | first | split: "?" | last | replace: "&", "&" }}{% endcapture %}
{%- assign pageQuerystring = pageUrl -%}
{%- assign parts = pageQuerystring | split:'&' -%}
{%- for part in parts -%}
{%- assign keyAndValue = part | split:'=' -%}
{{ keyAndValue[0] }}
{{ keyAndValue[1] }}
{%- endfor -%}
from shopify-code-snippets.
Another take: snippets/fn.qs.liquid (has to be a one-liner)
{% capture pageUrl %}{{ "tag" | link_to_add_tag: "tag" | split: 'href="' | last | split: '"' | first | split: "?" | last | replace: "&", "&" }}{% endcapture %}{%- assign pageQuerystring = pageUrl -%}{%- assign parts = pageQuerystring | split:'&' -%}{%- for part in parts -%}{%- assign keyAndValue = part | split:'=' -%}{% if keyAndValue[0] == param %}{{ keyAndValue[1] | replace: "%2C", "," }}{% endif %}{%- endfor -%}
Usage:
{% capture qs_q %}{%- render 'fn.qs', param: "q" -%}{% endcapture %}
{% assign q_values = qs_q | split: "," %}
<!-- -{{q_values[0]}}- -{{q_values[1]}}- -{{q_values[2]}}- -{{q_values[3]}}- -->
from shopify-code-snippets.
Nowadays, I just use the JavaScript's urlsearchparams for anything relating to querystrings. I appreciate all your guys' help!
from shopify-code-snippets.
Related Issues (9)
- Which Folder HOT 3
- update date_translate snippet to use localiszation object for automatic translation
- Is there any official documentation on these JSONP endpoints? HOT 2
- Search by SKU Snippet
- Shopify persitent cart without apps is not working HOT 2
- starts-with example doesn't give expected result
- Add other variables to outputted JSON, returning null? HOT 1
- Canβt get Shopify cart via jsonp crossdomain anymore HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopify-code-snippets.