Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Common things to check when experiencing problems with includes:
Check the syntax is correct, are you using commas ',' to separate parameters passed to the include and colons ':' to separate keys and values?
For Siteglide features, generally arrays are passed into variables as a comma-separated string e.g. item_ids: '1,2,3'- have you passed in as a Liquid array by mistake?
If you assign a variable inside a partial with the same name as the partial's filename it can cause a problem. E.g. if you are inside a file called marketplace_builder/views/partials/order.liquid
and you write the code:
...this can cause a bug.
Code Snippets are also referred to more globally as Includes because they're files that can be included in Pages, Templates, Headers/Footers etc. They're useful for things like external Javascript for Google Analytics as an example or Cookie Consent as in our Template Site:
They can be edited in Admin to leverage the Toolbox functionality or via CLI:
Includes are all of the following: Code Snippet, Content Section, Header, Footer.
See the file structure to understand where each file should be placed:
This is an example Include generated by Siteglide. Below, we'll list available YML parameters, and body content.
metadata
id
- Used by UI to reference Includes. Must be unique in the scope of that Include type (i.e. you could have ID=1 for both a Header and Footer) (required)
name
- Include name shown in UI (required)
file_type
- Used to define where the Include shows in UI.
Options: code_snippet
, content_section
, header
, footer
(required)
last_edit
- timestamp of last edit - shown in UI
physical_file_path
- Files should be stored in a location relative to their ID and file_type. If your ID is '3', and file_type is 'header', then the physical_file_path would be views/partials/includes/header/3.liquid
Files in the includes folder must be named with a unique number which matches the ID in their Yaml.
See the documentation for specific features to see where their layouts sit within the layouts folder. Code Editor in the Siteglide Admin normally starts its folder structure view at "layouts".
When using the "include" tag to include a partial Liquid file, the path should always start relative to the partials folder and it should not include the .liquid extension, as this is assumed.
The constants tag, automatically included at the top of all Siteglide pages and Page Templates gives access to several useful variables within that page.
However, some Liquid files, like automations (including email notifications), don't support a platformOS feature called exports which the constants include uses to give these variables scope in the page.
As a result, the constants include isn't fully supported in these settings.
Instead, we've provided a similar alternative constants_json which you can use in automations reliably.
Not Currently Supported
As transactional emails are sent asynchronously, it's not straightforward to implement the current_user and is_logged_in features of constants in the same way so they will not be currently supported.
We may in future add alternatives- by finding the details of the user who was logged in when the automation was queued.
Other Use Cases
You can use this function in Pages, however, be aware it could reduce performance if the page already contains the constants include - simply by duplicating the same functionality.
This is recommended at the top of most Pages and Page Templates if you are using Siteglide-CLI. It is not needed on the Siteglide Admin because it's included but hidden.
The Liquid tag include
is usually used to insert a Liquid Partial into a Liquid File.
Sometimes this can link to one of your files directly, simply pass in a String containing a custom path to your file. The path must start relative to the partials folder and must not include the file extension:
Sometimes it will link to a hidden Siteglide Module file, which may in turn include one of your customisable "layout" Liquid files.
To include one of Site's common include types, use these below and pass in the ID of the include (or the filename without the extension which will be the same). Name is a completely optional parameter.
The include tag will always pass down all variables initiated above it to the file that has been included.
These can be either implicit or explicitly passed:
For this example, implicit_variable
and explicit_variable
will have scope inside the partial file when it is rendered, but varible_with_no_scope
will not, simply because it is initialised after the include tag in the page.
There are also alternative tags which have a different inheritance behaviour:
If you want to pass variables from the partial file up to the page, you need to use either of these methods: