module (Banner)

This module component fetches data relating to Banner items.

{% component type: "module", source: "Banner", layout: "List" %}

Parameters and Options

Parameter Values Required Description
type module (default)
module_of_member

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

module is the standard retrieving function to retrieve all items.

module_of_member retrieves only those items "Added by" the currently logged in user (identified by the CreatedByMemberId property in the module items Liquid data).

The "Added by" System Property will only be available where the modules settings have "Allow Add New Items" turned on under the "Site User Permissions".

source Banner (default) The entity/alias name or ID that the data is to be sourced from.
layout List (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.

While this parameter is required to render your Layout markup, if the parameter is blank, has an incorrectly referenced Layout, or is removed altogether then the component will still output the modules item data to a Liquid collection which can be accessed via the collectionVariable parameter.

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 2 sample items but is otherwise the default structure you will get from this Component.

{
  "Pagination": {
  "CurrentPage": 1,
  "ItemsPerPage": 10,
  "NumberOfPages": 1,
  "TotalItemsCount": 2
},
  "Items": [
  {
    "Id": 2278,
    "Url": "/_banner_group/demo-standard-banner/demo-html-banner-item",
    "ParentId": 2277,
    "LastUpdatedDate": "2018-11-25T22:32:08",
    "Name": "DEMO HTML banner item",
    "UrlSlug": "demo-html-banner-item",
    "Enabled": true,
    "ReleaseDate": "2018-11-25T18:00:00",
    "ExpiryDate": "2099-12-11T07:00:00",
    "Weighting": 0,
    "Description": "",
    "ItemTags": null,
    "Author_Name": null,
    "Author_Url": null,
    "Author": "",
    "SEOTitle": "",
    "MetaTitle": "",
    "MetaDescription": "",
    "ShowPageForSearchEngine": false,
    "CanonicalLink": "",
    "EnableAMP": false,
    "AMPContent": "",
    "CodeEditor": false,
    "ExternalId": 0,
    "SocialMetaTags": "",
    "OpenGraphProperties": "",
    "DisableForSiteSearch": false,
    "SeoPriority": "",
    "CreatedByMemberId": 0,
    "ItemCategories": null,
    "ItemCategoryIdList": null,
    "SKUCode": "",
    "SiteSearchKeywords": "",
    "Module_ID": 1552,
    "Module_Alias": "Banner"
  },
  {
    "Id": 2294,
    "Url": "/_banner_group/demo-custom-banner/sample-banner-item",
    "ParentId": 2293,
    "LastUpdatedDate": "2018-12-15T09:55:14",
    "Name": "Sample Banner Item",
    "UrlSlug": "sample-banner-item",
    "Enabled": true,
    "ReleaseDate": "2018-12-15T18:00:00",
    "ExpiryDate": "2099-12-11T07:00:00",
    "Weighting": 0,
    "Description": "",
    "ItemTags": null,
    "Author_Name": null,
    "Author_Url": null,
    "Author": "",
    "SEOTitle": "",
    "MetaTitle": "",
    "MetaDescription": "",
    "ShowPageForSearchEngine": false,
    "CanonicalLink": "",
    "EnableAMP": false,
    "AMPContent": "",
    "CodeEditor": false,
    "ExternalId": 0,
    "SocialMetaTags": "",
    "OpenGraphProperties": "",
    "DisableForSiteSearch": false,
    "SeoPriority": "",
    "CreatedByMemberId": 0,
    "ItemCategories": null,
    "ItemCategoryIdList": null,
    "SKUCode": "",
    "SiteSearchKeywords": "",
    "Module_ID": 1552,
    "Module_Alias": "Banner"
  }
],
  "Params": {},
  "Parent": {
  "Id": 2147,
  "Url": "/component-types/module-banner",
  "ParentId": 2127,
  "LastUpdatedDate": "2020-05-20T00:49:12",
  "Name": "module (Banner)",
  "UrlSlug": "module-banner",
  "Enabled": true,
  "ReleaseDate": "2018-09-05T00:00:00",
  "ExpiryDate": "2099-12-09T00:00:00",
  "Weighting": 959,
  "Description": "<p>This module component fetches data relating to Banner items.</p>\r\n\r\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\r\n\r\n\r\n{% component type: \"snippet\", alias: \"section_parameters\" %}\r\n\r\n{% component type: \"snippet\", alias: \"param_table_head\" %}\r\n    {% component type: \"snippet\", alias: \"param_type\", required: \"true\", values: \"module <em>(default)</em>,module_of_member\" %}\r\n    {% component type: \"snippet\", alias: \"param_source\", required: \"true\", values: \"Banner <em>(default)</em>\" %}\r\n    {% component type: \"snippet\", alias: \"param_layout\", required: \"true\", values: \"List <em>(default)</em><br>&lt;Your Layout name&gt;\" %}\r\n    {% component type: \"snippet\", alias: \"param_filterby\" %}\r\n    {% component type: \"snippet\", alias: \"param_filtervalue\" %}\r\n    {% component type: \"snippet\", alias: \"param_sortby\" %}\r\n    {% component type: \"snippet\", alias: \"param_sortorder\" %}\r\n    {% component type: \"snippet\", alias: \"param_random\" %}\r\n    {% component type: \"snippet\", alias: \"param_limit\" %}\r\n    {% component type: \"snippet\", alias: \"param_enablepagination\" %}\r\n    {% component type: \"snippet\", alias: \"param_displaypagination\" %}\r\n    {% component type: \"snippet\", alias: \"param_emptymessage\" %}\r\n    {% component type: \"snippet\", alias: \"param_object\" %}\r\n    {% component type: \"snippet\", alias: \"param_collectionvariable\" %}\r\n    {% component type: \"snippet\", alias: \"param_issearchresult\" %}\r\n    {% component type: \"snippet\", alias: \"param_searchscope\" %}\r\n    {% component type: \"snippet\", alias: \"param_customparameter\" %}\r\n{% component type: \"snippet\", alias: \"param_table_foot\" %}\r\n\r\n\r\n{% component type: \"snippet\", alias: \"section_output\" %}\r\n\r\n{% component source: \"Banner\", layout: "", type: \"module\", collectionVariable: \"allBanners\" %}\r\n<p>The below example has 2 sample <code>items</code> but is otherwise the default structure you will get from this Component.</p>\r\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{allBanners}}\", lang: \"json\" %}\r\n\r\n{% component type: \"snippet\", alias: \"section_accessing_data\" %}\r\n\r\n<p>This data is accessible in two main ways:</p>\r\n\r\n<p>1. Using Liquid in the specified Layout via the <code>this</code> object.</p>\r\n\r\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\r\n\r\n<p>2. Directly on the Page or Template via a Liquid Collection if <code>collectionVariable</code> was added to the Component tag.</p>\r\n\r\n<p>An example using <code>collectionVariable</code> with value \"allBanners\" to list all \"Banner items\" across the site:</p>\r\n<p class=\"notice-note\">Here we suppress any Layout from rendering by setting <code>layout: \"\"</code> as an empty attribute.</p>\r\n\r\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\r\n\r\n<p><em>Looping through the collection to render all the item names in a list, giving us:</em></p>\r\n\r\n<ul>\r\n    \r\n        <li>DEMO HTML banner item</li>\r\n    \r\n        <li>Sample Banner Item</li>\r\n    \r\n</ul>\r\n<br>\r\n<p><em>The code:</em></p>\r\n\r\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\r\n\r\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>Sample Banner Item</code></em></p>\r\n\r\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\r\n\r\n<h2 id=\"secListFiltered\">List Banners items from a specific Banner Group</h2>\r\n<p>If you have more than one Banner Group on your site the above examples will list Banners from all Banner Groups as one single collection. However, you may also want to list all Banner items from only the Banner Group they belong to (their \"parent\" Banner Group).</p>\r\n<p>To do this we add the <code>filterBy</code> and <code>filterValue</code> attributes to the Component tag using the Banner Group's ID to get the relevant items.</p>\r\n<p class=\"notice-tip\">You can use the Component Manager to correctly configure the Component tag and ID value. Alternatively, to obtain the Banner Group's ID manually from the admin, go to a Banner's list view (where you can see all of the Banner items) and note the number in the browser address bar shown after the <code>parentID=</code> parameter.</p>\r\n\r\n{% component type: \"snippet\", alias: \"section_counter\" %}\r\n",
  "ItemTags": [
  "Banners"
],
  "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": false,
  "UpdateNotes": "'module_of_member' parameter details added.",
  "UpdatesLog": "",
  "ExternalResources": "",
  "AdditionalRelatedArticle_Name": "",
  "AdditionalRelatedArticle_Url": "",
  "AdditionalRelatedArticle": "",
  "AdditionalRelatedArticle2_Name": "",
  "AdditionalRelatedArticle2_Url": "",
  "AdditionalRelatedArticle2": "",
  "Authors": "2418",
  "Module_ID": 1870,
  "Module_Alias": "DocumentationPost",
  "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 "allBanners" to list all "Banner items" across the site:

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

{% component type: "module", source: "Banner", layout: "", collectionVariable: "allBanners" %}

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

  • DEMO HTML banner item
  • Sample Banner Item

The code:

<ul>
    {% for i in allBanners.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 Sample Banner Item

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

List Banners items from a specific Banner Group

If you have more than one Banner Group on your site the above examples will list Banners from all Banner Groups as one single collection. However, you may also want to list all Banner items from only the Banner Group they belong to (their "parent" Banner Group).

To do this we add the filterBy and filterValue attributes to the Component tag using the Banner Group's ID to get the relevant items.

You can use the Component Manager to correctly configure the Component tag and ID value. Alternatively, to obtain the Banner Group's ID manually from the admin, go to a Banner's list view (where you can see all of the Banner items) and note the number in the browser address bar shown after the parentID= parameter.

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

  • module (Banner Group)
    This module component fetches data relating to Banner Groups. {% capture data %} {% raw...
  • Banners
    Banners give you an easy way to display random banner ads, perhaps a random quote...

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.
Visit the Treepl Forum for community support and to search previously asked questions or send us a message at support@treepl.co and we will consult you as soon as possible.