Component Type: Module (Custom Modules)

This module component fetches data relating to Custom Modules.

{% component type: "module", source: "<Custom Module name/ID>", layout: "List 1" %}

Parameters and Options

Parameter Values Required Description
type module This is the name of the entity that needs to be used for the component retrieving function.
source <Custom Module name/ID> The entity/alias name or ID that the data is to be sourced from.
layout <Your Layout name> The layout name you want to use for rendering the component. The layout name is referenced from the available Layouts of the source specified. If the parameter is blank or has an incorrect referenced Layout then the component will not render any code.
filterBy id
parentid
name
weighting
url
urlslug
releasedate
expirydate
lastupdateddate
author
itemcategories
itemtags
<custompropertyname>
enableamp
ampcontent
canonicallink
codeeditor
createdbymemberid
description
disableforsitesearch
enabled
externalid
metadescription
opengraphproperties
seopriority
seotitle
showpageforsearchengine
socialmetatags

The name of the property to filter by. If empty or not present, no filtering will be used.

Remove spaces from custom property names here.

Values in italics may not be available in the Component Manager but can still be filtered by when added manually.

While these values may be present as properties in the Liquid collection, not all properties are configurable in all site plans.

filterValue <your value>
Your specific value to filter by, eg: name, id, number, date, etc.
Liquid variables can be used here also. If present but no value set, no items will be returned.
sortBy id
parentid
name
weighting
url
urlslug
releasedate
expirydate
lastupdateddate
author
itemcategories
itemtags
<custompropertyname>
enableamp
ampcontent
canonicallink
codeeditor
createdbymemberid
description
disableforsitesearch
enabled
externalid
metadescription
opengraphproperties
seopriority
seotitle
showpageforsearchengine
socialmetatags

The name of the property to sort by. If empty or not present, alpha/numeric sorting will be used.

Remove spaces from custom property names here.

Values in italics may not be available in the Component Manager but can still be sorted by when added manually.

While these values may be present as properties in the Liquid collection, not all properties are configurable in all site plans.

sortOrder ASC (default)
DESC

ASC sorts the items in ascending order while DESC sorts in descending order (based on alpha/numeric or date sorting).
If empty or not present, alpha/numeric sorting will be used.
random false (default)
true

Displays the available items in a random order.

If used in conjunction with sortBy, that sorting criteria will be applied to the randomly retrieved results. So, if retrieving all, or most, of the items they will not appear to be random since they will then be sorted back into a logical order. To overcome this, set the sortBy parameter to 'enabled' (or another unused property) as this will not provide any viable sorting criteria* and the items will not be sorted from their initial random order.
* Unless there are weighted items, which will always override the random option.

limit 10 (default)
<number>

The maximum number of items returned. If displayPagination is enabled this determines the maximum number of items per page.
displayPagination false (default)
true

Displays pagination if there are more items available than the limit set.
emptyMessage <Your custom message>
Custom content that is rendered if no items are returned by the Component. The default is no content.
Liquid variables are supported here, although Liquid logic tags and HTML are not.

If using Liquid variables with filters added, be sure to change any double quotes to single quotes. For eg:
emptyMessage: “{{ myVariable | prepend: 'Error: ' }}”

To use HTML in your empty message, first capture it using a Liquid capture, then insert the capture variable into the emptyMessage parameter.

object item (default)
collection

Determines the method for Liquid rendering.
item returns each item iteratively, one after another, for output (generally, output to a container element with no need for looping through the data).
collection returns all items as one collection for output (your container element and looping logic would be handled in the Components Layout).
collectionVariable <yourLiquidVariableName>
Assigns the data to a Liquid collection enabling further access to the data on the Page or Template using Liquid.
<customParameter> <your custom value>
You can add your own additional parameters (name/value pairs) to the Component tag. These will be passed to the Components Layout (and the collectionVariable if used) for use via Liquid.

You can use HTML as the value here, just be sure to change any double quotes in your HTML to single quotes.

Liquid Output

The below example has 4 sample items but is otherwise the default data you will get from this Component.

For Custom Modules this data will also include any custom properties/fields that you've added.

{
  "items": [
    {
      "id": 2262,
      "url": "/demo-web-technologies/css",
      "parentid": 2258,
      "lastupdateddate": "2019-03-03T16:54:30",
      "AMPContent": "",
      "Author_name": null,
      "Author_url": null,
      "Author": 0,
      "CanonicalLink": "",
      "CodeEditor": true,
      "CreatedByMemberId": 0,
      "CustomDatasourceProperty_name": "Null type",
      "CustomDatasourceProperty_url": "/demo-web-technologies/javascript/null-type",
      "CustomDatasourceProperty": 2267,
      "Description": "<p>CSS (Cascading Style Sheets) is used to describe presentation semantics i.e. how a document looks and feels.</p><p>It can be embedded directly inside tags (by using the <em>style</em> attribute) or inserted in the document head by using the&nbsp;<em>style</em>&nbsp;tag.</p><ul><div dir=\"ltr\"><br></div></ul>",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T16:54:29.7399709",
      "ExternalId": 0,
      "ItemCategories": null,
      "ItemTags": null,
      "MetaDescription": "",
      "MyCustomProperty1": "foobar",
      "MyCustomProperty2": "",
      "Name": "CSS",
      "OpenGraphProperties": "",
      "ReleaseDate": "2018-11-24T16:54:29.7399709",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "css",
      "Weighting": 0
    },
    {
      "id": 2263,
      "url": "/demo-web-technologies/html",
      "parentid": 2258,
      "lastupdateddate": "2019-02-28T20:44:56",
      "AMPContent": "",
      "Author_name": null,
      "Author_url": null,
      "Author": 0,
      "CanonicalLink": "",
      "CodeEditor": true,
      "CreatedByMemberId": 0,
      "CustomDatasourceProperty_name": null,
      "CustomDatasourceProperty_url": null,
      "CustomDatasourceProperty": null,
      "Description": "<p>The&nbsp;<strong>Hyper Text Markup Language</strong>&nbsp;(HTML) is mainly used for writing web pages. It is XML based and allows users to create structured text documents (by using tags and attributes) and insert text semantics (paragraphs, headers, tables, etc.).</p>\r\n\r\n<p>Usually it is used in conjuncture with&nbsp;<strong>JavaScript</strong>&nbsp;- which influences the behaviour of browsers - and&nbsp;<strong>CSS (Cascading Style Sheets)</strong>&nbsp;- for formating text and overall page appearance.</p>\r\n\r\n<p>Latest standard release by W3C was that of HTML 5.0 (ISO/IEC 15445:2000) in October 2014.</p>\r\n\r\n<p>In 2008 a draft for an HTML 5 was released. It includes several modifications:</p>\r\n\r\n<ul>\r\n<li>obsolete tags such as&nbsp;<em>font</em>,&nbsp;<em>frameset</em>&nbsp;or&nbsp;<em>center</em>&nbsp;were removed</li>\r\n<li>new tags such as&nbsp;<em>footer</em>,&nbsp;<em>audio</em>,&nbsp;<em>video</em>,&nbsp;<em>nav</em>, etc.</li>\r\n<li>new attributes such as&nbsp;<em>ping</em>,&nbsp;<em>async</em>, etc.</li>\r\n<li>new parsing mechanism</li>\r\n<li>ability to use SVG and MathML in text/html</li>\r\n<li>etc.</li>\r\n</ul>\r\n\r\n<p>Related languages include the&nbsp;<strong>XHTML</strong>&nbsp;1.1 which is an extension of HTML based on XML and not SGML.</p>\r\n\r\n<p>Three sub-specifications exist for both HTML and XHTML:</p>\r\n\r\n<ul>\r\n<li><strong>Strict</strong>: represents the standard proper and encourages the omission of presentational markup (eg. center or font tags) by using style sheets (CSS)</li>\r\n<li><strong>Transitional</strong>: allows for presentational markup</li>\r\n<li><strong>Frameset</strong>: allows for presentational markup and additionally from&nbsp;<em>Transitional</em>&nbsp;a frameset replacing body, containing frame elements, and optionally noframes, with a body</li>\r\n</ul>\r\n\r\n<p>Each document is checked against a DTD (Document Type Definition) file for validity.</p>",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T18:00:00",
      "ExternalId": 0,
      "ItemCategories": null,
      "ItemTags": null,
      "MetaDescription": "",
      "MyCustomProperty1": "sampledata",
      "MyCustomProperty2": "",
      "Name": "HTML",
      "OpenGraphProperties": "",
      "ReleaseDate": "2018-11-24T18:00:00",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "html",
      "Weighting": 0
    },
    {
      "id": 2264,
      "url": "/demo-web-technologies/javascript",
      "parentid": 2258,
      "lastupdateddate": "2019-02-28T20:44:56",
      "AMPContent": "",
      "Author_name": null,
      "Author_url": null,
      "Author": 0,
      "CanonicalLink": "",
      "CodeEditor": true,
      "CreatedByMemberId": 0,
      "CustomDatasourceProperty_name": null,
      "CustomDatasourceProperty_url": null,
      "CustomDatasourceProperty": null,
      "Description": "<p><strong>JavaScript</strong>&nbsp;(JS) is the name of Netscape Communications Corporation's and now the Mozilla’s foundation implementation of the&nbsp;<em>ECMAScript</em>&nbsp;standard, a scripting language based on the concept of prototype based programming.</p><p>The language is best known for its use in websites (as client side JavaScript), but is also used to enable scripting access to objects embedded in other applications.</p><p><strong>IMPORTANT</strong>: JavaScript is not Java!</p><p>JS can be used to do various things but it primarily comes into hand when:</p><ul><li>doing browser detection</li><li>handling cookies</li><li>controlling browsers</li><li>validating forms</li><li>setting CSS properties dynamically (see&nbsp;<a href=\"http://www.comptechdoc.org/independent/web/cgi/javamanual/javastyle.html\" rel=\"nofollow\">http://www.comptechdoc.org/independent/web/cgi/javamanual/javastyle.html</a>), eg.&nbsp;<em>element.style.border=\"1px solid black\"</em></li></ul>",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T18:00:00",
      "ExternalId": 0,
      "ItemCategories": null,
      "ItemTags": null,
      "MetaDescription": "",
      "MyCustomProperty1": "",
      "MyCustomProperty2": "",
      "Name": "Javascript",
      "OpenGraphProperties": "",
      "ReleaseDate": "2018-11-24T18:00:00",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "javascript",
      "Weighting": 0
    },
    {
      "id": 2265,
      "url": "/demo-web-technologies/liquid",
      "parentid": 2258,
      "lastupdateddate": "2019-02-28T20:44:57",
      "AMPContent": "",
      "Author_name": null,
      "Author_url": null,
      "Author": 0,
      "CanonicalLink": "",
      "CodeEditor": true,
      "CreatedByMemberId": 0,
      "CustomDatasourceProperty_name": null,
      "CustomDatasourceProperty_url": null,
      "CustomDatasourceProperty": null,
      "Description": "<p>Liquid is an open-source template language created by&nbsp;Shopify&nbsp;and written in Ruby. It is the backbone of Shopify themes and is used to load dynamic content on storefronts.</p><p>Liquid has been in production use at Shopify since 2006 and is now used by many other hosted web applications.</p>",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T18:00:00",
      "ExternalId": 0,
      "ItemCategories": null,
      "ItemTags": null,
      "MetaDescription": "",
      "MyCustomProperty1": "",
      "MyCustomProperty2": "",
      "Name": "Liquid",
      "OpenGraphProperties": "",
      "ReleaseDate": "2018-11-24T18:00:00",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "liquid",
      "Weighting": 0
    }
  ],
  "pagination": {
    "currentpage": 1,
    "itemsperpage": 10,
    "numberofpages": 1,
    "totalitemscount": 4
  },
  "params": {},
  "parent": {
    "id": 1960,
    "url": "/documentation_group/component-types/module-custom-modules",
    "parentid": 2127,
    "lastupdateddate": "2019-06-06T20:41:38",
    "Active": true,
    "AdditionalRelatedArticle_name": null,
    "AdditionalRelatedArticle_url": null,
    "AdditionalRelatedArticle": null,
    "AMPContent": "",
    "Author_name": null,
    "Author_url": null,
    "Author": null,
    "Authors": "2418",
    "CanonicalLink": "",
    "CodeEditor": false,
    "CreatedByMemberId": 0,
    "Description": "<p>This module component fetches data relating to Custom Modules.</p>\n{% capture data %}\n{% raw %}\n{% component type: \"module\", source: \"<Custom Module name/ID>\", layout: \"List 1\" %}\n{% endraw %}\n{% endcapture %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n\n{% component type: \"snippet\", alias: \"section_parameters\" %}\n\n{% component type: \"snippet\", alias: \"param_table_head\" %}\n    {% component type: \"snippet\", alias: \"param_type\", required: \"true\" %}\n    {% component type: \"snippet\", alias: \"param_source\", required: \"true\" %}\n    {% component type: \"snippet\", alias: \"param_layout\", required: \"true\" %}\n    {% component type: \"snippet\", alias: \"param_filterby\" %}\n    {% component type: \"snippet\", alias: \"param_filtervalue\" %}\n    {% component type: \"snippet\", alias: \"param_sortby\" %}\n    {% component type: \"snippet\", alias: \"param_sortorder\" %}\n    {% component type: \"snippet\", alias: \"param_random\" %}\n    {% component type: \"snippet\", alias: \"param_limit\" %}\n    {% component type: \"snippet\", alias: \"param_displaypagination\" %}\n    {% component type: \"snippet\", alias: \"param_emptymessage\" %}\n    {% component type: \"snippet\", alias: \"param_object\" %}\n    {% component type: \"snippet\", alias: \"param_collectionvariable\" %}\n    {% component type: \"snippet\", alias: \"param_customparameter\" %}\n{% component type: \"snippet\", alias: \"param_table_foot\" %}\n\n\n{% component type: \"snippet\", alias: \"section_output\" %}\n\n<p>The below example has 4 sample <code>items</code> but is otherwise the default data you will get from this Component.</p>\n\n<p>For Custom Modules this data will also include any custom properties/fields that you've added.</p>\n\n{% component source: \"DEMO Web Technologies\", layout: \"\", collectionVariable: \"webTech\", type: \"module\" %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{webTech}}\", lang: \"json\" %}\n\n{% component type: \"snippet\", alias: \"section_accessing_data\" %}\n\n<p>This data is accessible in two main ways:</p>\n\n<p>1. Using Liquid in the specified Layout via the <code>this</code> object.</p>\n{% capture data %}\n{% raw %}\n{{this['url']}}\n{% endraw %}\n{% endcapture %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<p>2. Directly on the Page or Template via a Liquid Collection if <code>collectionVariable</code> was added to the Component tag.</p>\n\n<p>An example using <code>collectionVariable</code> with value \"webTech\" for a Custom Module called \"Web Technologies\":</p>\n{% capture data %}\n{% raw %}\n{% component type: \"module\", source: \"Web Technologies\", layout: \"List 1\", collectionVariable: \"webTech\" %}\n{% endraw %}\n{% endcapture %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<p><em>Looping through the collection to render all the item URLs in a list, giving us:</em></p>\n\n<ul>\n    {% for i in webTech.items %}\n        <li>{{i['url']}}</li>\n    {% endfor %}\n</ul>\n<br>\n<p><em>The code:</em></p>\n{% capture data %}\n{% raw %}\n<ul>\n    {% for i in webTech.items %}\n        <li>{{i['url']}}</li>\n    {% endfor %}\n</ul>\n{% endraw %}\n{% endcapture %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<p><em>Accessing a specific item within the collection. In this case the third item (zero based index), which in our example would render the value <code>/web-technologies/javascript/</code></em></p>\n{% capture data %}\n{% raw %}\n{{webTech.items[2]['url']}}\n{% endraw %}\n{% endcapture %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n\n{% component type: \"snippet\", alias: \"section_counter\" %}\n",
    "DisableForSiteSearch": false,
    "EnableAMP": false,
    "Enabled": true,
    "ExpiryDate": "2099-10-10T00:00:00",
    "ExternalId": 0,
    "ExternalResources": "",
    "IgnoreUpdates": true,
    "ItemCategories": null,
    "ItemTags": [
      "Custom Modules"
    ],
    "MetaDescription": "",
    "Name": "module (Custom Modules)",
    "OpenGraphProperties": "",
    "ReleaseDate": "2018-06-19T00:00:00",
    "SeoPriority": "",
    "SEOTitle": "Component Type: Module (Custom Modules)",
    "MetaTitle": "Component Type: Module (Custom Modules)",
    "ShowPageForSearchEngine": true,
    "SocialMetaTags": "",
    "UpdateNotes": "Updated 'filterBy' and 'sortBy' values",
    "UrlSlug": "module-custom-modules-",
    "Weighting": 930,
    "parentname": "Component Types",
    "parenturl": "/documentation_group/component-types",
    "templatename": "Docs Template-1",
    "ishome": false
  }
}

Accessing the Data

This data is accessible in two main ways:

1. Using Liquid in the specified Layout via the this object.

{{this['url']}}

2. Directly on the Page or Template via a Liquid Collection if collectionVariable was added to the Component tag.

An example using collectionVariable with value "webTech" for a Custom Module called "Web Technologies":

{% component type: "module", source: "Web Technologies", layout: "List 1", collectionVariable: "webTech" %}

Looping through the collection to render all the item URLs in a list, giving us:

  • /demo-web-technologies/css
  • /demo-web-technologies/html
  • /demo-web-technologies/javascript
  • /demo-web-technologies/liquid

The code:

<ul>
    {% for i in webTech.items %}
        <li>{{i['url']}}</li>
    {% endfor %}
</ul>

Accessing a specific item within the collection. In this case the third item (zero based index), which in our example would render the value /web-technologies/javascript/

{{webTech.items[2]['url']}}

Counter

Along with the data output above, there is also a special liquid tag available {{counter}} which increments for each item. This tag is only available within Layouts when object: "item" is used in the Component tag.



Related Articles

External Resources

There are currently no external resources available.

Please let us know if you have any other contributions or know of any helpful resources you'd like to see added here.


Questions?

We are always happy to help with any questions you may have.
Send us a message at support@treepl.co and we will consult you as soon as possible.