module (Page)

This module component fetches data relating to Pages.

Possible use cases for this are creating dynamic menus or automatic on-page sitemaps. Specifically, creating a dynamic on-page sub-menu (of all the pages within the current folder/directory).

Pages are based on the same structure as many other modules in Treepl CMS. So you can retrieve, list, sort and filter your site pages just like you might Blog Posts or Custom Modules.

{% component type: "module", source: "Page", layout: "Page Detail" %}

Parameters and Options

Parameter Values Required Description
type module (default)

This is the name of the entity that needs to be used for the component retrieving function.

source Page (default) The entity/alias name or ID that the data is to be sourced from.
layout Page Detail (default)
<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>
...and any other top level properties available for the module

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.

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>
...and any other top level properties available for the module

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.

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.
enablePagination true (default)
false

Enables/disables pagination for the component.

This is useful for avoiding pagniation affects for a specific component when multiple components of the same module are output on the same page and do use pagination.

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.

Your collectionVariable value must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

isSearchResult false (default)
true

Allows search parameters in the URL to override the components output. Therefore, this parameter can be used to output module specific search results from a submitted search form.

Likewise, Tag, Category, and Archive components can be used in conjunction with this parameter for filtering the module's output.

URL search parameters will override any corresponding parameters in the component. If no search parameters are present in the URL, isSearchResult will be ignored.

Any value other than true, (including an empty value), will disable the search functionality and the component will output its regular data.

searchScope eg:
{'prop_ParentId':'1234', 'prop_ReleaseDate_Min':'2018-07-01', 'prop_ReleaseDate_Max':'2018-07-31', 'prop_KeyWords':'Your Keywords', 'prop_ItemTags':['tag1','tag2'], 'page':'2'}

Allows a search on the module without search parameters needed in the URL. Instead, search parameters are added to the value of this parameter. Therefore, this parameter can be used to output module specific search results from hard-coded (or Liquid) values without the use of a search form.

Added search parameters will override any corresponding parameters otherwise configured on the component. If no search parameters are present, searchScope will be ignored.

This value supports Liquid and can therefore be constructed with Liquid data/variables.

<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.

Your <customParameter> name must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

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 3 sample items (due to a limit applied) but is otherwise the default structure you will get from this Component.

{
  "Pagination": {
  "CurrentPage": 1,
  "ItemsPerPage": 3,
  "NumberOfPages": 7,
  "TotalItemsCount": 19
},
  "Items": [
  {
    "Id": 2225,
    "Url": "/demo-cs/index",
    "ParentId": 2224,
    "LastUpdatedDate": "2019-02-28T20:45:39",
    "Name": "_Home",
    "UrlSlug": "index",
    "Enabled": true,
    "ReleaseDate": "2018-11-24T18:00:00",
    "ExpiryDate": "2099-12-10T18:00:00",
    "Weighting": 0,
    "Description": "<div>\r\n    <h1>A Demo Site for Treepl CMS Docs</h1>\r\n    <p class=\"lead\">Treepl CMS is an all-in-one system for creating ever-growing websites.<br>For designers, for coders, for agencies - for you!</p>\r\n    <p>For the official documentation <a href=\"https://docs.treepl.co/\" rel=\"noopener noreferrer\" target=\"_blank\">see here</a>.</p>\r\n</div>",
    "ItemTags": null,
    "Author_Name": null,
    "Author_Url": null,
    "Author": "",
    "SEOTitle": "Docs Demo Site for Treepl CMS",
    "MetaTitle": "Docs Demo Site for Treepl CMS",
    "MetaDescription": "Treepl CMS is an all-in-one system for creating ever-growing websites.\r\nFor designers, for coders, for agencies - for you!",
    "ShowPageForSearchEngine": true,
    "CanonicalLink": "",
    "EnableAMP": false,
    "AMPContent": "",
    "CodeEditor": true,
    "ExternalId": 0,
    "SocialMetaTags": "",
    "OpenGraphProperties": {
      "title": "",
      "type": "",
      "url": "",
      "locale": "",
      "image": ""
    },
    "DisableForSiteSearch": false,
    "SeoPriority": "",
    "CreatedByMemberId": 0,
    "ItemCategories": null,
    "ItemCategoryIdList": null,
    "SKUCode": "",
    "SiteSearchKeywords": "",
    "FtpFullPath": "Content\\Pages\\demo-cs\\index.html"
  },
  {
    "Id": 2538,
    "Url": "/_sandbox",
    "ParentId": -1,
    "LastUpdatedDate": "2020-05-23T19:43:40",
    "Name": "_sandbox",
    "UrlSlug": "_sandbox",
    "Enabled": true,
    "ReleaseDate": "2020-05-07T00:00:00",
    "ExpiryDate": "2099-12-11T13:00:00",
    "Weighting": 0,
    "Description": "<img src=\"/images/documentation/module-edit-settings.png?watermark=hello\" alt=\"a\">\n{% component type:\"grouped_items\", source: \"Products\", itemId: \"2535\", filterBy: \"Name\", filterValue: \"DEMO product 2\", collectionVariable: \"addData\" %}\n@<pre></pre>@\n<hr>\n\n\n#4#<br><br>\n\n1-me<br>\n\n2-you<br>\n\n3-them<br>\n\n4-us<br>\n\n\n<hr>\n<form>\n\t<input type=\"hidden\" name=\"prop_ModuleId\" value=\"2493\" >\n\t<label>Keywords</label>\n\t<input type=\"text\" name=\"prop_KeyWords\" maxlength=\"255\" value=\"\" >\n\n\t<input type=\"submit\" value=\"Search\" >\n</form>\n\n{% component source: \"Catalogs\", type: \"module\", searchScope: \"{'prop_ModuleId':'2493', 'prop_KeyWord':'2'}\" %}\n<hr>\n\n{% component type: \"orders\", collectionVariable: \"dataC\" %}\n<pre></pre>\n<hr>\n\n{% component source: \"Catalogs\", type: \"module\", collectionVariable: \"data\" %}\n<pre>
{% component type: "module", source: "Page", layout: "Page Detail" %}
</pre>",
    "ItemTags": null,
    "Author_Name": null,
    "Author_Url": null,
    "Author": "",
    "SEOTitle": "",
    "MetaTitle": "",
    "MetaDescription": "",
    "ShowPageForSearchEngine": false,
    "CanonicalLink": "",
    "EnableAMP": false,
    "AMPContent": "",
    "CodeEditor": true,
    "ExternalId": 0,
    "SocialMetaTags": "",
    "OpenGraphProperties": "",
    "DisableForSiteSearch": true,
    "SeoPriority": "0.5",
    "CreatedByMemberId": 0,
    "ItemCategories": null,
    "ItemCategoryIdList": null,
    "SKUCode": "",
    "SiteSearchKeywords": "",
    "FtpFullPath": "Content\\Pages\\_sandbox.html"
  },
  {
    "Id": 2227,
    "Url": "/demo-cs/ajax-form",
    "ParentId": 2224,
    "LastUpdatedDate": "2019-02-28T20:45:34",
    "Name": "AJAX Form",
    "UrlSlug": "ajax-form",
    "Enabled": true,
    "ReleaseDate": "2018-11-24T18:00:00",
    "ExpiryDate": "2099-12-10T18:00:00",
    "Weighting": 0,
    "Description": "{% component type: \"form\", alias: \"demo_ajax_example\", collectionVariable: \"formData\" %}\r\n\r\n\r\n<h1>Basic AJAX Form Submission Demo</h1>\r\n<div class=\"grid-x grid-padding-x\">\r\n    <div class=\"cell medium-6\">\r\n        <p>{% component type: \"form\", alias: \"demo_ajax_example\" %}</p>\r\n    </div>\r\n    <div class=\"cell medium-6\">\r\n        <ul class=\"tabs\" data-tabs id=\"code-tabs\">\r\n            <li class=\"tabs-title is-active\"><a href=\"#panel1\" aria-selected=\"true\">Form Code</a></li>\r\n            <li class=\"tabs-title\"><a data-tabs-target=\"panel2\" href=\"#panel2\">Liquid Output</a></li>\r\n        </ul>\r\n        <div class=\"tabs-content\" data-tabs-content=\"code-tabs\">\r\n            <div class=\"tabs-panel is-active\" id=\"panel1\">\r\n                <p class=\"callout warning\">NOTE: This script assumes jQuery is being loaded on your site.</p>\r\n                <pre>{% component type: \&quot;form\&quot;, alias: \&quot;demo_ajax_example\&quot; %}</pre>\r\n            </div>\r\n            <div class=\"tabs-panel\" id=\"panel2\">\r\n                <pre></pre>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>",
    "ItemTags": null,
    "Author_Name": null,
    "Author_Url": null,
    "Author": "",
    "SEOTitle": "",
    "MetaTitle": "",
    "MetaDescription": "",
    "ShowPageForSearchEngine": true,
    "CanonicalLink": "",
    "EnableAMP": false,
    "AMPContent": "",
    "CodeEditor": true,
    "ExternalId": 0,
    "SocialMetaTags": "",
    "OpenGraphProperties": "",
    "DisableForSiteSearch": false,
    "SeoPriority": "",
    "CreatedByMemberId": 0,
    "ItemCategories": null,
    "ItemCategoryIdList": null,
    "SKUCode": "",
    "SiteSearchKeywords": "",
    "FtpFullPath": "Content\\Pages\\demo-cs\\ajax-form.html"
  }
],
  "Params": {},
  "Parent": {
  "Id": 2160,
  "Url": "/component-types/module-page",
  "ParentId": 2127,
  "LastUpdatedDate": "2020-05-01T06:10:11",
  "Name": "module (Page)",
  "UrlSlug": "module-page",
  "Enabled": true,
  "ReleaseDate": "2018-09-20T00:00:00",
  "ExpiryDate": "2099-12-10T00:00:00",
  "Weighting": 900,
  "Description": "<p>This module component fetches data relating to Pages.</p>\n<p>Possible use cases for this are creating dynamic menus or automatic on-page sitemaps. Specifically, creating a dynamic on-page sub-menu (of all the pages within the current folder/directory).</p>\n<p class=\"notice-tip\">Pages are based on the same structure as many other modules in Treepl CMS. So you can retrieve, list, sort and filter your site pages just like you might Blog Posts or Custom Modules.</p>\n\n\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\", values: \"Page <em>(default)</em>\" %}\n    {% component type: \"snippet\", alias: \"param_layout\", required: \"true\", values: \"Page Detail <em>(default)</em><br>&lt;Your Layout name&gt;\" %}\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_enablepagination\" %}\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_issearchresult\" %}\n    {% component type: \"snippet\", alias: \"param_searchscope\" %}\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{% component source: \"Page\", layout: "", type: \"module\", collectionVariable: \"allPages\", limit: \"3\" %}\n<p>The below example has 3 sample <code>items</code> (due to a <code>limit</code> applied) but is otherwise the default structure you will get from this Component.</p>\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{allPages}}\", 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\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 \"allPages\" to list all \"Page items\" across the site:</p>\n<p class=\"notice-note\">Here we suppress any Layout from rendering by setting <code>layout: \"\"</code> as an empty attribute.</p>\n\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 names in a list, giving us:</em></p>\n\n<ul>\n    \n        <li>_Home</li>\n    \n        <li>_sandbox</li>\n    \n        <li>AJAX Form</li>\n    \n</ul>\n<br>\n<p><em>The code:</em></p>\n\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 second item (zero based index), which in our example would render the value <code>_sandbox</code></em></p>\n\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<p class=\"notice-warning\">Avoid calling all pages, while rendering their content description, via this module when on a Page as this will cause the module to retrieve itself and trigger an infinite loop and a system error will occur.<br>\nInstead, try being specific with the page/s you need to retrieve using the <code>filterBy</code> options or avoid rendering the content description field.</p>\n\n<h2 id=\"secListFiltered\">List a Specific Page</h2>\n<p>If you want to only list a single specific Page you could filter the items using the Page's ID or perhaps even its name.</p>\n<p>To do this we add the <code>filterBy</code> and <code>filterValue</code> attributes to the Component tag using the specific Page's ID (or their name) to get just that item. For example:</p>\n\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<h3>Dynamic Sub-Page Menu</h3>\n<p>Let's say you want to have a dynamic on-page menu that lists all pages with the currently viewed folder/directory.</p>\n<p>To do this, we can get the parent ID of the current page (which is the Folder ID) and filter the Page list by <code>parentID</code>.</p>\n\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<p class=\"notice-note\">You <b>cannot</b> use the Component Manager to configure the Component tag for Pages as it's not generally part of the content management process that clients may need to utilise.</p>\n\n{% component type: \"snippet\", alias: \"section_counter\" %}\n",
  "ItemTags": [
  "Pages"
],
  "Author_Name": "",
  "Author_Url": "",
  "Author": "",
  "SEOTitle": "",
  "MetaTitle": "",
  "MetaDescription": "",
  "ShowPageForSearchEngine": true,
  "CanonicalLink": "",
  "EnableAMP": false,
  "AMPContent": "",
  "CodeEditor": true,
  "ExternalId": 0,
  "SocialMetaTags": "",
  "OpenGraphProperties": "",
  "DisableForSiteSearch": false,
  "SeoPriority": "",
  "CreatedByMemberId": 0,
  "ItemCategories": "",
  "ItemCategoryIdList": "",
  "SKUCode": "",
  "SiteSearchKeywords": "",
  "Active": true,
  "IgnoreUpdates": true,
  "UpdateNotes": "'isSearchResult' and 'searchScope' parameter details added.",
  "ExternalResources": "",
  "AdditionalRelatedArticle_Name": "",
  "AdditionalRelatedArticle_Url": "",
  "AdditionalRelatedArticle": "",
  "AdditionalRelatedArticle2_Name": "",
  "AdditionalRelatedArticle2_Url": "",
  "AdditionalRelatedArticle2": "",
  "Authors": "2418",
  "ParentName": "Liquid Components",
  "ParentUrl": "/component-types",
  "TemplateName": "Docs Template",
  "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['name']}}

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 "allPages" to list all "Page items" across the site:

Here we suppress any Layout from rendering by setting layout: "" as an empty attribute.

{% component type: "module", source: "Page", layout: "", collectionVariable: "allPages" %}

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

  • _Home
  • _sandbox
  • AJAX Form

The code:

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

Accessing a specific item within the collection. In this case the second item (zero based index), which in our example would render the value _sandbox

{{allPages.items[1]['name']}}

Avoid calling all pages, while rendering their content description, via this module when on a Page as this will cause the module to retrieve itself and trigger an infinite loop and a system error will occur.
Instead, try being specific with the page/s you need to retrieve using the filterBy options or avoid rendering the content description field.

List a Specific Page

If you want to only list a single specific Page you could filter the items using the Page's ID or perhaps even its name.

To do this we add the filterBy and filterValue attributes to the Component tag using the specific Page's ID (or their name) to get just that item. For example:

{% component type: "module", source: "Page", layout: "Page Detail", filterBy: "id", filterValue: "1865" %}
or
{% component type: "module", source: "Page", layout: "Page Detail", filterBy: "name", filterValue: "Documentation" %}

Dynamic Sub-Page Menu

Let's say you want to have a dynamic on-page menu that lists all pages with the currently viewed folder/directory.

To do this, we can get the parent ID of the current page (which is the Folder ID) and filter the Page list by parentID.

{% component type: "module", source: "Page", filterBy: "parentid", filterValue: "{{this.parentID}}", collectionVariable: "subPages" %}
<ul>
{% for i in subPages.items %}
    <li><a href="{{i.url}}">{{i.name}}</a></li>
{% endfor %}
</ul>

You cannot use the Component Manager to configure the Component tag for Pages as it's not generally part of the content management process that clients may need to utilise.

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

  • System Pages
    System Pages, under 'Settings', is where you’ll find all those pages required by certain system...
  • Pages
    Pages allow the creation and management of standard page content and folders. Pages can be...
  • module (Page Folder)
    This module component fetches data relating to Page Folders. Possible use cases for this are...

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.