Skip to content
  1. Extras
  2. PageBuilder
  3. Section catalog
  4. Pro
  5. Blog posts

Blog posts

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

Информация

Requires PageBuilder Pro.

What the blog feed adds

  • Feed from child resources, no hand-rolled pdo in templates
  • Limit and sort in inspector
  • Intro and thumbnail toggles

Where to place

  • Blog homepage: latest posts
  • Site homepage: "From the blog" block
  • Landing: three recent articles

Page examples

Parent and limit

Blog parent: resource ID or picker. Limit, Sort, Show intro / image flags.

Similar sections

Block parameters

ParameterValue
keyblog_posts
LayerPro
Categorycontent (content)
Chunkpagebuilderpro_blog_posts
Requirespro

Inspector fields

Fill these fields in the section inspector. Field types are documented in the field types reference.

Title (title)

Type text. Optional.

Blog parent (parent)

Type relation. Required. Pick one MODX resource in a search modal.

Limit (limit)

Type number. Optional.

Show intro (show_intro)

Type yesno. Optional. Yes/no toggle.

Show image (show_image)

Type yesno. Optional. Yes/no toggle.

Sort (sortby)

Type select. Optional. Dropdown with predefined options.

Layout (layout)

Type select. Optional. Dropdown with predefined options.

Site output

pb-blog-posts with article cards.

Section data

Example payload after save. Media, video, and map values may be enriched on output:

json
{
  "title": "Section title",
  "parent": 101,
  "limit": 6,
  "show_intro": true,
  "show_image": true,
  "sortby": "menuindex",
  "layout": "grid"
}

Chunk template

Fenom chunk pagebuilderpro_blog_posts:

fenom
<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}
    <div class="pb-blog-posts__listing">
      {var $includeTvs = ($show_image|default:0) ? 'image' : ''}
      {$modx->runSnippet('pdoResources', [
        'parents' => $parent.id|default:($parent_id|default:0),
        'depth' => 1,
        'limit' => $limit|default:6,
        'sortby' => $blog_sortby|default:'publishedon',
        'sortdir' => $blog_sortdir|default:'DESC',
        'includeContent' => $show_intro|default:0,
        'includeTVs' => $includeTvs,
        'tpl' => 'pagebuilderpro_blog_post_row'
      ])}
    </div>
  </div>
</section>

JSON definition

PageBuilderPro/core/components/pagebuilderpro/sections/blog_posts.json

See also