Dynamic Blocks & Shortcodes

Dynamic blocks (also called shortcodes) are blocks that show live content. Instead of typing a list of posts or services into a page, you drop in a block, choose what it should show, and TruCMS builds the list from your real data every time the page is viewed.

The Blocks panel scrolled to the Content and Booking blocks

Live blocks appear in the Blocks panel under categories such as Content, Forms, Booking and the TruCommerce groups.

How dynamic blocks work

A dynamic block is stored on the page as a small placeholder together with the options you chose (for example layout: List, limit: 6). When someone views the page, TruCMS replaces the placeholder with up-to-date content. That means:

Dynamic blocks and data-bound sections

Dynamic blocks read your data every time the page loads. Data-bound sections are designer layouts whose content is filled in from a record you pick and refreshed whenever that record changes. Use dynamic blocks for lists and functions (a booking form, a cart); use data-bound sections for richly designed presentations.

Using a dynamic block

  1. In the Page Builder, open the Blocks panel and find the block in its category (use the search box).
  2. Drag it onto the page. The editor shows a loading placeholder, then a live preview.
  3. With the block selected, open Settings (the gear). Choose what it should show; the preview updates as you change options.
  4. Required choices are marked in the table below. If one is missing the block says Select … to load the preview.
  5. Save the page.
Settings panel of a selected Booking Services block

A selected block and its options in the Settings panel.

Kinds of option

ControlHow to use it
ChoiceA menu of fixed choices. Many blocks have a Layout choice that picks one of several designs.
On / offA checkbox that shows or hides a part, for example Show price or Pagination.
Text / NumberType a value, for example the number of items or a button label.
Search and pickStart typing to search your own records (services, products, advertisements) and choose one.

Block catalogue

The blocks below are available on every site. Blocks that belong to a module are documented with that module: Booking Page Builder Components and TruCommerce Blocks & Widgets.

Blog

A simple list of your latest published blog posts, in the blog style of your theme.

OptionControlChoices
PostsNumber—
Category IDsText—
Excluded category IDsText—
OrderChoiceLatest, Oldest, Title, Random, Popular (default: Latest)
PaginationOn / off—

Category options take category numbers separated by commas (shown in the Categories list in the admin).

Blog Cards

Your published posts as designed cards in six layouts: a Classic grid, Horizontal rows, an Editorial overlay, a Slider, a Magazine arrangement and a Minimal list. Use it for “latest news” sections on home pages.

OptionControlChoices
LayoutChoiceClassic grid, Horizontal, Editorial overlay, Slider, Magazine, Minimal list
TypeChoiceRecent, Popular (default: Recent)
Categories (IDs or slugs)Text—
Excluded categories (IDs or slugs)Text—
SearchText—
PostsNumber—
ColumnsNumber—
PaginationOn / off—

Categories can be given as numbers or as their names’ slugs, separated by commas.

Advertisements

Shows one of your advertisements where you place the block.

OptionControlChoices
Advertisement requiredSearch and pick—

Share

Social sharing buttons for the current page, or for an address and title you provide.

OptionControlChoices
LayoutChoiceDefault
URLText—
TitleText—

Widgets

Displays all the widgets of one widget area inside the page, for example the Footer Area 1 widgets or the Blog sidebar. Enter the area’s identifier: sidebar (Homepage), categories-sidebar, tags-sidebar, pages-sidebar, post-sidebar (Blog), footer-1 to footer-6, trucommerce-shop-sidebar, trucommerce-product-sidebar, trucommerce-cart-sidebar or trucommerce-checkout-sidebar.

OptionControlChoices
Widget area requiredText—

Contact

The site’s contact form. Visitors fill it in and the message is sent to the administration email set in Settings → General. If reCAPTCHA for the contact page is switched on there, the form includes it.

OptionControlChoices
LayoutChoiceFull (default: Full)

Where blocks appear

Dynamic blocks belong to page content, so they work on any page you build in the Page Builder, including the pages you assign in Settings → Page Setup as your shop, cart, checkout or booking pages. The blog posts pages and the built-in module pages have their own fixed designs; use the matching block to show the same information in a page of your own.

Troubleshooting

SymptomWhat to do
The block shows nothing on the public pageThere may be nothing to show (no published posts, no active services) or a filter is too narrow. Check the options, and that the module is enabled.
The editor says Select … to load the previewOpen Settings and fill the required Search and pick option.
The preview could not be loadedCheck the selected values and try again. A deleted record chosen earlier can cause this: pick another.
A change to the data is not on the pageA cached copy of the page may be served. See the FAQ.

Page Builder · Data-Bound Sections · Widgets · Booking Page Builder Components · TruCommerce Blocks & Widgets