Posts Section
The Posts Section Block displays posts from the Blog entry type according to specified settings. The section's display behavior is controlled by the following settings:
- settings.enable_blog: Defined in the Settings
- section.reverse_order: A boolean value indicating whether the posts should be displayed in reverse order.
- section.show_specific_items: A boolean value indicating whether specific posts should be displayed.
- section.specific_items: An array of specific posts to display, if- section.show_specific_itemsis- true.
- section.filter_by_category: A boolean value indicating whether the posts should be filtered by category.
- section.post_category_filter: The category to filter posts by, if- section.filter_by_categoryis- true.
- section.sort_by: A string value indicating how to sort the posts. Possible values are- 'title'or- 'date'.
- section.enable_pagination: A boolean value indicating whether to display the posts with pagination.
- section.limit: An integer value indicating the number of posts to display per page, if- section.enable_paginationis- true.
Based on these settings, the code is executing the following operations:
- If - section.show_specific_itemsis- true, the code initializes an empty array- postsand pushes specific posts into it.
- If - section.filter_by_categoryis- true, the code filters the- postsarray to only include posts that belong to the specified category.
- If - section.sort_byis- 'title', the code sorts the- postsarray either ascending or descending based on- section.reverse_order. If- section.show_specific_itemsis- false, the code sorts the posts using the- orderByfunction, otherwise, the code sorts the posts using the- sortByfunction.
- If - section.sort_byis- 'date', the code sorts the- postsarray either ascending or descending based on- section.reverse_orderby post's published date.
- If - section.enable_paginationis- true, the code paginates the- postsarray using the- paginateCustomfunction. Otherwise, the code limits the number of posts to- section.limitusing the- limitfunction.
- The code then generates HTML to display the posts in the blog section, using the specified HTML tag, anchor, CSS classes, and styles. For each post, the code displays the post's title, author, and image. 
The section's tag name is either section or the section.html_tag in the Advanced Tab fields if you have it set. The Advanced Tab fields also add an ID attribute and CSS Classes that you specify. You can also adjust the Bootstrap container type as well in this tab. 
You can also adjust the spacing before and after using the switches from section.disable_top_spacing, and section.disable_bottom_spacing respectfully.
Note: This code requires additional context and information about the Twig functions used (e.g. collect, whereRelation, sortBy, orderBy(Similar to sortBy), paginateCustom, page, resize, etc.) to fully understand the implementation.
Files Used
The following files are used to display this content
- builder/blog/*included in the- builder.yamlfile
- builder/section/posts.htmpartial used to display Blog Posts
Last updated
