Difference between revisions of "Liquid Template Variables - request"
From Spiffy Stores Knowledge Base
(22 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The Liquid template variable '''request''' has the following attributes: | The Liquid template variable '''request''' has the following attributes: | ||
− | |||
== <code>request.''parameter''</code> == | == <code>request.''parameter''</code> == | ||
− | |||
You can access any request parameter by name. | You can access any request parameter by name. | ||
Line 12: | Line 10: | ||
<pre>request.theme</pre> | <pre>request.theme</pre> | ||
− | |||
== <code>request.host</code> == | == <code>request.host</code> == | ||
− | |||
Returns the host name portion of the URL request. | Returns the host name portion of the URL request. | ||
− | For example, if we go to <nowiki>http://storedemo.spiffystores.com</nowiki>, then the request.host returns: | + | For example, if we go to ''<nowiki>http://storedemo.spiffystores.com</nowiki>'', then the '''request.host''' returns: |
<pre>storedemo.spiffystores.com</pre> | <pre>storedemo.spiffystores.com</pre> | ||
− | |||
== <code>request.url</code> == | == <code>request.url</code> == | ||
− | |||
Returns the complete URL used for this request. | Returns the complete URL used for this request. | ||
− | For example, if we go to <nowiki>http://storedemo.spiffystores.com/products/widget</nowiki>, then the request.url returns: | + | For example, if we go to ''<nowiki>http://storedemo.spiffystores.com/products/widget</nowiki>'', then the '''request.url''' returns: |
<pre>http://storedemo.spiffystores.com/products/widget</pre> | <pre>http://storedemo.spiffystores.com/products/widget</pre> | ||
+ | == <code>request.referer</code> == | ||
+ | Returns the referer URL for this request. | ||
+ | For example, if we came to the current page from ''<nowiki>http://storedemo.spiffystores.com/collections/widgets</nowiki>'', then the '''request.referer''' returns: | ||
+ | |||
+ | <pre>http://storedemo.spiffystores.com/collections/widgets</pre> | ||
== <code>request.remote_ip</code> == | == <code>request.remote_ip</code> == | ||
− | + | Returns the IP address of the user accessing the page. | |
− | Returns the IP address of the | ||
− | |||
== <code>request.country</code> == | == <code>request.country</code> == | ||
+ | Returns the Country name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate. | ||
− | + | The name returned is the ISO Printable name. For example: | |
− | |||
− | The name returned is the ISO Printable name. For example | ||
<pre> | <pre> | ||
Australia | Australia | ||
</pre> | </pre> | ||
− | |||
== <code>request.country_code</code> == | == <code>request.country_code</code> == | ||
+ | Returns the two character ISO Country Code of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate. | ||
− | + | The code returned is the ISO Code. For example: | |
− | |||
− | The code returned is the ISO Code. For example | ||
<pre> | <pre> | ||
AU | AU | ||
</pre> | </pre> | ||
+ | == <code>request.province</code> == | ||
+ | Returns the Province/State name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate. | ||
− | == <code>request. | + | The name returned is the ISO Printable name. For example: |
+ | |||
+ | <pre> | ||
+ | New South Wales | ||
+ | </pre> | ||
+ | == <code>request.province_code</code> == | ||
+ | Returns the two character ISO Province/State Code of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate. | ||
− | + | The code returned is the ISO Code. For example: | |
− | For example | + | <pre> |
+ | NSW | ||
+ | </pre> | ||
+ | == <code>request.city</code> == | ||
+ | Returns the City name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 79% accurate. For example: | ||
<pre> | <pre> | ||
Sydney | Sydney | ||
</pre> | </pre> | ||
− | |||
== <code>request.timezone</code> == | == <code>request.timezone</code> == | ||
− | + | Returns the Time Zone of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. For example, if the user is using a proxy, then the time zone of the proxy server will be returned, rather than that of the user. | |
− | Returns the Time Zone of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. | ||
The name returned is the standard timezone name. For example: | The name returned is the standard timezone name. For example: | ||
Line 72: | Line 76: | ||
Australia/Sydney | Australia/Sydney | ||
</pre> | </pre> | ||
+ | == <code>request.utc_offset</code> == | ||
+ | JavaScript code is inserted in every page to detect the UTC offset on a user's computer. This value, in seconds, is set as a cookie, which can be retrieved and returned here. | ||
+ | This value gives an accurate reading of the user's time zone and will probably be more accurate than '''request.timezone'''. | ||
+ | |||
+ | No value is available when the initial page is displayed, as the JavaScript to calculate the time zone offset has not had a chance to run. | ||
+ | == <code>request.client_time</code> == | ||
+ | Returns the best available guess for the current time on the user's computer. If the '''request.utc_offset''' value is available, then this is used to calculate the time zone. If this value is not available, then the time zone that has been derived from the IP address is used, and failing that, the local time for the store is used. | ||
== <code>request.currency</code> == | == <code>request.currency</code> == | ||
− | |||
Returns the local currency of the user, based upon the Country from which the client has accessed the page. This information is determined from the IP address, and may not be accurate in all cases. | Returns the local currency of the user, based upon the Country from which the client has accessed the page. This information is determined from the IP address, and may not be accurate in all cases. | ||
Line 80: | Line 90: | ||
AUD | AUD | ||
</pre> | </pre> | ||
− | |||
== <code>request.user_agent</code> == | == <code>request.user_agent</code> == | ||
− | |||
Returns the user agent string of the user's browser. Each browser returns a unique user agent string, which provides information about the version and features that the browser provides. | Returns the user agent string of the user's browser. Each browser returns a unique user agent string, which provides information about the version and features that the browser provides. | ||
Line 88: | Line 96: | ||
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0 | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0 | ||
</pre> | </pre> | ||
+ | == <code>request.browser</code> == | ||
+ | Returns the name of the user's browser. | ||
+ | |||
+ | <pre> | ||
+ | Firefox | ||
+ | </pre> | ||
+ | == <code>request.browser_version</code> == | ||
+ | Returns the version of the user's browser. | ||
+ | |||
+ | <pre> | ||
+ | 25.0 | ||
+ | </pre> | ||
+ | == <code>request.browser_platform</code> == | ||
+ | Returns the platform of the user's browser. This will be the generic type of operating system that the user is running, such as Windows or Macintosh. | ||
+ | |||
+ | <pre> | ||
+ | Windows | ||
+ | </pre> | ||
+ | == <code>request.browser_os</code> == | ||
+ | Returns the operating system that the user's browser is running under. | ||
+ | |||
+ | <pre> | ||
+ | Windows 7 | ||
+ | </pre> | ||
+ | == <code>request.mobile?</code> == | ||
+ | Returns true if the user's browser is running on a mobile device. | ||
+ | == <code>request.tablet?</code> == | ||
+ | Returns true if the user's browser is running on a tablet device. | ||
+ | |||
+ | == <code>request.bot?</code> == | ||
+ | Returns true if the request appears to be coming from a robot or web crawler. | ||
+ | == <code>request.ajax?</code> == | ||
+ | Returns true if the request is using Ajax to render part of the page. | ||
+ | == <code>request.locale</code> == | ||
+ | Returns the shop_locale of the current request. | ||
+ | == <code>request.page_type</code> == | ||
+ | Returns the type of the current page. These are the different page types: | ||
+ | |||
+ | * 404 | ||
+ | * article | ||
+ | * blog | ||
+ | * cart | ||
+ | * collection | ||
+ | * list-collections | ||
+ | * customers/account | ||
+ | * customers/activate_account | ||
+ | * customers/addresses | ||
+ | * customers/login | ||
+ | * customers/order | ||
+ | * customers/register | ||
+ | * customers/reset_password | ||
+ | * index | ||
+ | * page | ||
+ | * password | ||
+ | * product | ||
+ | * search | ||
+ | == Further Reference == | ||
+ | |||
+ | * [[Liquid Basics]] | ||
+ | * [[Liquid Tag Reference]] | ||
+ | * [[Liquid Filter Reference]] | ||
+ | * [[Liquid Variable Reference]] | ||
+ | * [[Liquid Paginate Tag|Pagination ]] |
Latest revision as of 16:51, 14 July 2022
The Liquid template variable request has the following attributes:
Contents
- 1 request.parameter
- 2 request.host
- 3 request.url
- 4 request.referer
- 5 request.remote_ip
- 6 request.country
- 7 request.country_code
- 8 request.province
- 9 request.province_code
- 10 request.city
- 11 request.timezone
- 12 request.utc_offset
- 13 request.client_time
- 14 request.currency
- 15 request.user_agent
- 16 request.browser
- 17 request.browser_version
- 18 request.browser_platform
- 19 request.browser_os
- 20 request.mobile?
- 21 request.tablet?
- 22 request.bot?
- 23 request.ajax?
- 24 request.locale
- 25 request.page_type
- 26 Further Reference
request.parameter
You can access any request parameter by name.
For example, a URL can include a parameter:
http://storedemo.spiffystores.com/?theme=blue
This theme parameter can be accessed by
request.theme
request.host
Returns the host name portion of the URL request.
For example, if we go to http://storedemo.spiffystores.com, then the request.host returns:
storedemo.spiffystores.com
request.url
Returns the complete URL used for this request.
For example, if we go to http://storedemo.spiffystores.com/products/widget, then the request.url returns:
http://storedemo.spiffystores.com/products/widget
request.referer
Returns the referer URL for this request.
For example, if we came to the current page from http://storedemo.spiffystores.com/collections/widgets, then the request.referer returns:
http://storedemo.spiffystores.com/collections/widgets
request.remote_ip
Returns the IP address of the user accessing the page.
request.country
Returns the Country name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.
The name returned is the ISO Printable name. For example:
Australia
request.country_code
Returns the two character ISO Country Code of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.
The code returned is the ISO Code. For example:
AU
request.province
Returns the Province/State name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.
The name returned is the ISO Printable name. For example:
New South Wales
request.province_code
Returns the two character ISO Province/State Code of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 99.5% accurate.
The code returned is the ISO Code. For example:
NSW
request.city
Returns the City name of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. Typically, the results are 79% accurate. For example:
Sydney
request.timezone
Returns the Time Zone of the user accessing the page. This information is determined from the IP address, and may not be accurate in all cases. For example, if the user is using a proxy, then the time zone of the proxy server will be returned, rather than that of the user.
The name returned is the standard timezone name. For example:
Australia/Sydney
request.utc_offset
JavaScript code is inserted in every page to detect the UTC offset on a user's computer. This value, in seconds, is set as a cookie, which can be retrieved and returned here.
This value gives an accurate reading of the user's time zone and will probably be more accurate than request.timezone.
No value is available when the initial page is displayed, as the JavaScript to calculate the time zone offset has not had a chance to run.
request.client_time
Returns the best available guess for the current time on the user's computer. If the request.utc_offset value is available, then this is used to calculate the time zone. If this value is not available, then the time zone that has been derived from the IP address is used, and failing that, the local time for the store is used.
request.currency
Returns the local currency of the user, based upon the Country from which the client has accessed the page. This information is determined from the IP address, and may not be accurate in all cases.
AUD
request.user_agent
Returns the user agent string of the user's browser. Each browser returns a unique user agent string, which provides information about the version and features that the browser provides.
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
request.browser
Returns the name of the user's browser.
Firefox
request.browser_version
Returns the version of the user's browser.
25.0
request.browser_platform
Returns the platform of the user's browser. This will be the generic type of operating system that the user is running, such as Windows or Macintosh.
Windows
request.browser_os
Returns the operating system that the user's browser is running under.
Windows 7
request.mobile?
Returns true if the user's browser is running on a mobile device.
request.tablet?
Returns true if the user's browser is running on a tablet device.
request.bot?
Returns true if the request appears to be coming from a robot or web crawler.
request.ajax?
Returns true if the request is using Ajax to render part of the page.
request.locale
Returns the shop_locale of the current request.
request.page_type
Returns the type of the current page. These are the different page types:
- 404
- article
- blog
- cart
- collection
- list-collections
- customers/account
- customers/activate_account
- customers/addresses
- customers/login
- customers/order
- customers/register
- customers/reset_password
- index
- page
- password
- product
- search