
- MODX 3
- PHP 8.2
- Vue 3


Automatic article feed: set blog parent, limit, and sort. Intros and thumbnails come from resources.

Информация
Requires PageBuilder Pro.
Blog parent: resource ID or picker. Limit, Sort, Show intro / image flags.
| Parameter | Value |
|---|---|
| key | blog_posts |
| Layer | Pro |
| Category | content (content) |
| Chunk | pagebuilderpro_blog_posts |
| Requires | pro |
Fill these fields in the section inspector. Field types are documented in the field types reference.
title) Type text. Optional.
parent) Type relation. Required. Pick one MODX resource in a search modal.
limit) Type number. Optional.
show_intro) Type yesno. Optional. Yes/no toggle.
show_image) Type yesno. Optional. Yes/no toggle.
sortby) Type select. Optional. publishedon_desc (newest first), publishedon_asc (oldest first), menuindex (menu order).
layout) Type select. Optional. grid, featured-first, compact-list.
pb-blog-posts with article cards. An empty parent or an empty listing prints lexicon pagebuilder_fe_listing_empty_blog. The intro comes from introtext and shows only when show_intro is on. The image (TV image) shows only when show_image is on.
Example payload after save. Media, video, and map values may be enriched on output:
{
"title": "Section title",
"parent": 101,
"limit": 6,
"show_intro": true,
"show_image": true,
"sortby": "menuindex",
"layout": "grid"
}Fenom chunk pagebuilderpro_blog_posts:
{set $blogParent = $parent.id|default:($parent_id|default:0)}
{set $showIntro = $show_intro|default:0}
{set $showImage = $show_image|default:0}
{set $includeTvs = $showImage ? 'image' : ''}
{set $listing = ''}
{if $blogParent}
{set $listing = $modx->runSnippet('pdoResources', [
'parents' => $blogParent,
'depth' => 1,
'limit' => $limit|default:6,
'sortby' => $blog_sortby|default:'publishedon',
'sortdir' => $blog_sortdir|default:'DESC',
'includeTVs' => $includeTvs,
'tvPrefix' => '',
'show_intro' => $showIntro,
'show_image' => $showImage,
'tpl' => 'pagebuilderpro_blog_post_row'
])}
{/if}
<section class="pb-section pb-section--blog-posts pb-blog-posts pb-blog-posts--{$layout|default:'grid'|escape}{if $cssClass} {$cssClass|escape}{/if}" data-pb-section="blog_posts"{if $id} id="pb-{$id|escape}"{/if}>
<div class="pb-section__inner pb-blog-posts__inner">
{if $title}
<h2 class="pb-heading pb-blog-posts__title">{$title|escape}</h2>
{/if}
{if $listing}
<div class="pb-blog-posts__listing">
{$listing}
</div>
{else}
<p class="pb-listing__empty">{'pagebuilder_fe_listing_empty_blog' | lexicon}</p>
{/if}
</div>
</section>