module (Blog Post)

This module component fetches data relating to Blog Posts.

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

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 Blog Post (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. 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 structure you will get from this Component.

{
  "items": [
    {
      "id": 2280,
      "url": "/demo-html-blog/demo-html-post",
      "parentid": 2279,
      "lastupdateddate": "2019-02-28T20:44:52",
      "AMPContent": "",
      "Author_name": "DEMO Author One",
      "Author_url": "/_author/demo-author-one",
      "Author": 2274,
      "CanonicalLink": "",
      "CodeEditor": true,
      "CreatedByMemberId": 0,
      "Description": "<p>Orci phasellus egestas tellus rutrum tellus pellentesque. Sed enim ut sem viverra aliquet. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Eget duis at tellus at urna condimentum mattis pellentesque. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Viverra aliquet eget sit amet tellus cras adipiscing enim.</p><p><span class=\"fr-emoticon fr-deletable fr-emoticon-img\" style=\"background: url(https://cdnjs.cloudflare.com/ajax/libs/emojione/2.0.1/assets/svg/1f60e.svg);\">&nbsp;</span>&nbsp;</p>\r\n",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T16:55:52.8064367",
      "ExternalId": 0,
      "Image": null,
      "ItemCategories": null,
      "ItemTags": null,
      "MetaDescription": "",
      "Name": "DEMO HTML Post",
      "OpenGraphProperties": "",
      "ReleaseDate": "2018-11-25T16:55:52.8064367",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "demo-html-post",
      "Weighting": 0
    },
    {
      "id": 2287,
      "url": "/demo-custom-blog/sample-post-one",
      "parentid": 2286,
      "lastupdateddate": "2019-02-28T20:44:52",
      "AMPContent": "",
      "Author_name": "DEMO Author One",
      "Author_url": "/_author/demo-author-one",
      "Author": 2274,
      "CanonicalLink": "",
      "CodeEditor": true,
      "CreatedByMemberId": 0,
      "Description": "<p>Orci phasellus egestas tellus rutrum tellus pellentesque. Sed enim ut sem viverra aliquet. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Eget duis at tellus at urna condimentum mattis pellentesque. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Viverra aliquet eget sit amet tellus cras adipiscing enim.</p>\r\n<p>Non tellus orci ac auctor augue mauris. In hendrerit gravida rutrum quisque non. Morbi tempus iaculis urna id volutpat lacus laoreet. Nulla aliquet enim tortor at. Erat velit scelerisque in dictum non. Neque gravida in fermentum et sollicitudin ac orci phasellus. Luctus venenatis lectus magna fringilla urna porttitor. Lorem sed risus ultricies tristique nulla aliquet. Non consectetur a erat nam.</p>\r\n<p>Fames ac turpis egestas maecenas. Nibh sit amet commodo nulla facilisi. Id eu nisl nunc mi ipsum faucibus vitae aliquet. Quis viverra nibh cras pulvinar. Enim nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Orci eu lobortis elementum nibh tellus molestie nunc. Ut sem nulla pharetra diam sit amet. Massa vitae tortor condimentum lacinia quis vel eros.</p>\r\n<p>Sodales ut eu sem integer vitae justo eget. At risus viverra adipiscing at in tellus integer. Ac odio tempor orci dapibus ultrices. Diam ut venenatis tellus in metus vulputate eu scelerisque felis. Commodo ullamcorper a lacus vestibulum.</p>",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T18:00:00",
      "ExternalId": 0,
      "Image": "/images/community-img-01.jpg",
      "ItemCategories": [
        "Blog: News & Events"
      ],
      "ItemTags": [
        "demo",
        "blog post",
        "sample"
      ],
      "MetaDescription": "",
      "Name": "Sample Post One",
      "OpenGraphProperties": "",
      "ReleaseDate": "2018-12-14T18:00:00",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "sample-post-one",
      "Weighting": 0
    },
    {
      "id": 2319,
      "url": "/demo-custom-blog/sample-post-three",
      "parentid": 2286,
      "lastupdateddate": "2019-02-28T20:44:53",
      "AMPContent": "",
      "Author_name": null,
      "Author_url": null,
      "Author": 0,
      "CanonicalLink": "",
      "CodeEditor": false,
      "CreatedByMemberId": 0,
      "Description": "<p>Orci phasellus egestas tellus rutrum tellus pellentesque. Sed enim ut sem viverra aliquet. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Eget duis at tellus at urna condimentum mattis pellentesque. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Viverra aliquet eget sit amet tellus cras adipiscing enim.</p><p>Non tellus orci ac auctor augue mauris. In hendrerit gravida rutrum quisque non. Morbi tempus iaculis urna id volutpat lacus laoreet. Nulla aliquet enim tortor at. Erat velit scelerisque in dictum non. Neque gravida in fermentum et sollicitudin ac orci phasellus. Luctus venenatis lectus magna fringilla urna porttitor. Lorem sed risus ultricies tristique nulla aliquet. Non consectetur a erat nam.</p><p>Fames ac turpis egestas maecenas. Nibh sit amet commodo nulla facilisi. Id eu nisl nunc mi ipsum faucibus vitae aliquet. Quis viverra nibh cras pulvinar. Enim nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Orci eu lobortis elementum nibh tellus molestie nunc. Ut sem nulla pharetra diam sit amet. Massa vitae tortor condimentum lacinia quis vel eros.</p><p>Sodales ut eu sem integer vitae justo eget. At risus viverra adipiscing at in tellus integer. Ac odio tempor orci dapibus ultrices. Diam ut venenatis tellus in metus vulputate eu scelerisque felis. Commodo ullamcorper a lacus vestibulum.</p><p>Orci phasellus egestas tellus rutrum tellus pellentesque. Sed enim ut sem viverra aliquet. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Eget duis at tellus at urna condimentum mattis pellentesque. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Viverra aliquet eget sit amet tellus cras adipiscing enim.</p><p>Non tellus orci ac auctor augue mauris. In hendrerit gravida rutrum quisque non. Morbi tempus iaculis urna id volutpat lacus laoreet. Nulla aliquet enim tortor at. Erat velit scelerisque in dictum non. Neque gravida in fermentum et sollicitudin ac orci phasellus. Luctus venenatis lectus magna fringilla urna porttitor. Lorem sed risus ultricies tristique nulla aliquet. Non consectetur a erat nam.</p><p>Fames ac turpis egestas maecenas. Nibh sit amet commodo nulla facilisi. Id eu nisl nunc mi ipsum faucibus vitae aliquet. Quis viverra nibh cras pulvinar. Enim nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Orci eu lobortis elementum nibh tellus molestie nunc. Ut sem nulla pharetra diam sit amet. Massa vitae tortor condimentum lacinia quis vel eros.</p><p>Sodales ut eu sem integer vitae justo eget. At risus viverra adipiscing at in tellus integer. Ac odio tempor orci dapibus ultrices. Diam ut venenatis tellus in metus vulputate eu scelerisque felis. Commodo ullamcorper a lacus vestibulum.</p>",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T18:00:00",
      "ExternalId": 0,
      "Image": "/images/community-img-01.jpg",
      "ItemCategories": null,
      "ItemTags": null,
      "MetaDescription": "",
      "Name": "Sample Post Three",
      "OpenGraphProperties": "",
      "ReleaseDate": "2019-01-18T18:00:00",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "sample-post-three",
      "Weighting": 0
    },
    {
      "id": 2288,
      "url": "/demo-custom-blog/sample-post-two",
      "parentid": 2286,
      "lastupdateddate": "2019-02-28T20:44:53",
      "AMPContent": "",
      "Author_name": "DEMO Author One",
      "Author_url": "/_author/demo-author-one",
      "Author": 2274,
      "CanonicalLink": "",
      "CodeEditor": true,
      "CreatedByMemberId": 0,
      "Description": "<p>Orci phasellus egestas tellus rutrum tellus pellentesque. Sed enim ut sem viverra aliquet. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Eget duis at tellus at urna condimentum mattis pellentesque. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Viverra aliquet eget sit amet tellus cras adipiscing enim.</p>\r\n<p>Non tellus orci ac auctor augue mauris. In hendrerit gravida rutrum quisque non. Morbi tempus iaculis urna id volutpat lacus laoreet. Nulla aliquet enim tortor at. Erat velit scelerisque in dictum non. Neque gravida in fermentum et sollicitudin ac orci phasellus. Luctus venenatis lectus magna fringilla urna porttitor. Lorem sed risus ultricies tristique nulla aliquet. Non consectetur a erat nam.</p>\r\n<p>Fames ac turpis egestas maecenas. Nibh sit amet commodo nulla facilisi. Id eu nisl nunc mi ipsum faucibus vitae aliquet. Quis viverra nibh cras pulvinar. Enim nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Orci eu lobortis elementum nibh tellus molestie nunc. Ut sem nulla pharetra diam sit amet. Massa vitae tortor condimentum lacinia quis vel eros.</p>\r\n<p>Sodales ut eu sem integer vitae justo eget. At risus viverra adipiscing at in tellus integer. Ac odio tempor orci dapibus ultrices. Diam ut venenatis tellus in metus vulputate eu scelerisque felis. Commodo ullamcorper a lacus vestibulum.</p>\r\n<p>Orci phasellus egestas tellus rutrum tellus pellentesque. Sed enim ut sem viverra aliquet. Sed euismod nisi porta lorem mollis aliquam ut porttitor. Eget duis at tellus at urna condimentum mattis pellentesque. A condimentum vitae sapien pellentesque habitant morbi tristique senectus et. Viverra aliquet eget sit amet tellus cras adipiscing enim.</p>\r\n<p>Non tellus orci ac auctor augue mauris. In hendrerit gravida rutrum quisque non. Morbi tempus iaculis urna id volutpat lacus laoreet. Nulla aliquet enim tortor at. Erat velit scelerisque in dictum non. Neque gravida in fermentum et sollicitudin ac orci phasellus. Luctus venenatis lectus magna fringilla urna porttitor. Lorem sed risus ultricies tristique nulla aliquet. Non consectetur a erat nam.</p>\r\n<p>Fames ac turpis egestas maecenas. Nibh sit amet commodo nulla facilisi. Id eu nisl nunc mi ipsum faucibus vitae aliquet. Quis viverra nibh cras pulvinar. Enim nulla aliquet porttitor lacus luctus accumsan tortor posuere ac. Orci eu lobortis elementum nibh tellus molestie nunc. Ut sem nulla pharetra diam sit amet. Massa vitae tortor condimentum lacinia quis vel eros.</p>\r\n<p>Sodales ut eu sem integer vitae justo eget. At risus viverra adipiscing at in tellus integer. Ac odio tempor orci dapibus ultrices. Diam ut venenatis tellus in metus vulputate eu scelerisque felis. Commodo ullamcorper a lacus vestibulum.</p>",
      "DisableForSiteSearch": false,
      "EnableAMP": false,
      "Enabled": true,
      "ExpiryDate": "2099-12-10T18:00:00",
      "ExternalId": 0,
      "Image": "/images/partner-img-01.jpg",
      "ItemCategories": [
        "Blog: News & Events",
        "Blog: Special Deals"
      ],
      "ItemTags": [
        "blog post",
        "sample"
      ],
      "MetaDescription": "",
      "Name": "Sample Post Two",
      "OpenGraphProperties": "",
      "ReleaseDate": "2018-12-12T18:00:00",
      "SeoPriority": "",
      "SEOTitle": "",
      "MetaTitle": "",
      "ShowPageForSearchEngine": true,
      "SocialMetaTags": "",
      "UrlSlug": "sample-post-two",
      "Weighting": 0
    }
  ],
  "pagination": {
    "currentpage": 1,
    "itemsperpage": 10,
    "numberofpages": 1,
    "totalitemscount": 4
  },
  "params": {},
  "parent": {
    "id": 2142,
    "url": "/documentation_group/component-types/module-blog-post",
    "parentid": 2127,
    "lastupdateddate": "2019-06-06T20:41:37",
    "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": "\n\n<p>This module component fetches data relating to Blog Posts.</p>\n{% capture data %}\n{% raw %}\n{% component type: \"module\", source: \"Blog Post\", layout: \"List\" %}\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\", values: \"Blog Post <em>(default)</em>\" %}\n    {% component type: \"snippet\", alias: \"param_layout\", required: \"true\", values: \"List <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_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{% component source: \"Blog Post\", layout: \"\", type: \"module\", collectionVariable: \"allPosts\" %}\n<p>The below example has {{allPosts.pagination.totalitemscount}} sample <code>items</code> but is otherwise the default structure you will get from this Component.</p>\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{allPosts}}\", 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 \"allPosts\" to list all \"Blog Posts\" 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{% capture data %}\n{% raw %}\n{% component type: \"module\", source: \"Blog Posts\", layout: \"\", collectionVariable: \"allPosts\" %}\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 allPosts.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 allPosts.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>{{allPosts.items[2]['url']}}</code></em></p>\n{% capture data %}\n{% raw %}\n{{allPosts.items[2]['url']}}\n{% endraw %}\n{% endcapture %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<h2 id=\"secListFilteredPosts\">List Posts from a specific Blog</h2>\n<p>If you have more than one Blog on your site the above examples will list Posts from all Blogs as one single collection. However, typically you'd want to list all Posts from only the Blog they belong to (their \"parent\" Blog).</p>\n<p>To do this we add the <code>filterBy</code> and <code>filterValue</code> attributes to the Component tag.</p>\n<p>Typically, you would be listing Blog specific Posts on your Blog detail page/index page. In which case you would be editing the 'General Blog Layout' to insert your Component tag, which would look like this:</p>\n{% capture data %}\n{% raw %}\n{% component type: \"module\", source: \"Blog Posts\", layout: \"List\", filterBy: \"parentId\", filterValue: \"{{this['id']}}\" %}\n{% endraw %}\n{% endcapture %}\n{% component type: \"snippet\", alias: \"code_block_processor\", data: \"{{data}}\", lang: \"liquid\" %}\n\n<p>As we are within the Blog's detail Layout (which represents the 'parent' Blog) we can reference its ID for the filter value using <code>{% raw %}{{this['id']}}{% endraw %}</code> and instruct the Component tag to filter the Posts only by their parent (<code>filterBy: \"parentID\"</code>) - giving us only the relevant Posts for the current Blog.</p>\n<p>You may however, want to render a list of Posts on a standard page or within another modules layout,  where the Post's parent ID (the Blog it belongs to) is not readily available to us in the Liquid scope. In this case you would need to manually hardcode the desired parent Blog's ID into the component tag in place of the above Liquid generated ID (<code>filterValue: \"1234\"</code>).</p>\n<p class=\"notice-tip\">To obtain the Blog's ID from the admin, go to that Blog's list view (where you can see all of the Posts) and note the number in the URL address bar shown after the <code>parentID=</code> parameter.</p>\n\n{% component type: \"snippet\", alias: \"section_counter\" %}\n",
    "DisableForSiteSearch": false,
    "EnableAMP": false,
    "Enabled": true,
    "ExpiryDate": "2099-12-09T00:00:00",
    "ExternalId": 0,
    "ExternalResources": "<ul><li><a href=\"/demo-cs/all-posts\">Demo Site All Posts</a></li><li><a href=\"/demo-html-blog\">Demo Site Blog</a></li></ul>",
    "IgnoreUpdates": true,
    "ItemCategories": null,
    "ItemTags": [
      "Blogs"
    ],
    "MetaDescription": "",
    "Name": "module (Blog Post)",
    "OpenGraphProperties": "",
    "ReleaseDate": "2018-09-05T00:00:00",
    "SeoPriority": "",
    "SEOTitle": "",
    "MetaTitle": "",
    "ShowPageForSearchEngine": true,
    "SocialMetaTags": "",
    "UpdateNotes": "All new article",
    "UrlSlug": "module-blog-post-",
    "Weighting": 969,
    "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 "allPosts" to list all "Blog Posts" across the site:

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

{% component type: "module", source: "Blog Posts", layout: "", collectionVariable: "allPosts" %}

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

  • /demo-html-blog/demo-html-post
  • /demo-custom-blog/sample-post-one
  • /demo-custom-blog/sample-post-three
  • /demo-custom-blog/sample-post-two

The code:

<ul>
    {% for i in allPosts.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 /demo-custom-blog/sample-post-three

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

List Posts from a specific Blog

If you have more than one Blog on your site the above examples will list Posts from all Blogs as one single collection. However, typically you'd want to list all Posts from only the Blog they belong to (their "parent" Blog).

To do this we add the filterBy and filterValue attributes to the Component tag.

Typically, you would be listing Blog specific Posts on your Blog detail page/index page. In which case you would be editing the 'General Blog Layout' to insert your Component tag, which would look like this:

{% component type: "module", source: "Blog Posts", layout: "List", filterBy: "parentId", filterValue: "{{this['id']}}" %}

As we are within the Blog's detail Layout (which represents the 'parent' Blog) we can reference its ID for the filter value using {{this['id']}} and instruct the Component tag to filter the Posts only by their parent (filterBy: "parentID") - giving us only the relevant Posts for the current Blog.

You may however, want to render a list of Posts on a standard page or within another modules layout, where the Post's parent ID (the Blog it belongs to) is not readily available to us in the Liquid scope. In this case you would need to manually hardcode the desired parent Blog's ID into the component tag in place of the above Liquid generated ID (filterValue: "1234").

To obtain the Blog's ID from the admin, go to that Blog's list view (where you can see all of the Posts) and note the number in the URL 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 (Blog)
    This module component fetches data relating to Blogs. {% component type: "module", source: "Blog", layout:...
  • Blogs
    Blogs provide a robust blogging platform allowing multiple Blogs per site with unlimited Posts and...

External Resources


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.