Search code examples
business-catalyst

alternate the display of module_blogsitepost


How can I display the {module_blogsitepost} according to what I want? For example I have a list of post in blog module how can I display in reverse or make the old post make it to first display when I call the {module_blogsitepost}. I tried to change their release date but still doesnt work.


Solution

  • You can achieve a custom display of {module_blogsitepost} using Liquid markup using the following:

    {module_blogsitepost rowCount="X" collection="custom-collection-name" template=""}
    

    (Where "rowCount" is the number of blog posts displayed).

    For more info on this, refer to the Business Catalyst documentation on {module_blogsitepost}.

    The above markup puts all the data available in {module_blogsitepost} into a collection called "custom-collection-name". You can view the data stored in "custom-collection-name" using <pre> {{ custom-collection-name | json }} </pre> (place this on your page).

    Here is an example of how to create your own custom display of the module, specifically in reverse order. Use the keyword reversed:

    {% for item in custom-collection-name.items reversed -%}
    
        <div class="blog-post">
            <h2 class="post-title">{{item.title}}</h2>
            <div class="post-details">
                {{item.author}} | {{item.date}}
            </div>
            <div class="post-body">
                {{item/body}}
            </div>
        </div>
    
    {% endfor -%}
    

    Note: It is important to realise that the Liquid output of this module does not include the truncated blog post like {module_blogsitepost} does by default. The above will output the entire blog post and you will need to look at ways to truncate the data contained in {{item.body}}.

    You will most likely want to manipulate the output of {{item.date}} as well. See the Business Catalyst documentation on Date Switches.