Hand-written Includes in-depth notes
Content Block content_block
No call site in this site yet
Renders one content block component (the orchestrated kind from the component library in the admin) by its code.
content_block($component, array $options = [])
Pages Home Single pages
How do I read these repository paths?
All paths are relative to the site root. Open core/tpl_functions.php at line 298 to see the definition of content_block(). The "core method" is what the tag actually forwards to: a template writes content_list(...) and the core runs Tpl::contentList(...).
1. Fill in parameters, get the code Edit any field and the result below updates instantly; press Copy and paste it into a template. It also works without JavaScript: press Generate and the server recomputes it.
click the title to collapse / expand
Now generating: content_block
This is the real rendering of the page (real header, container, this tag output, real footer). It reloads when you change a parameter.
Refreshing…
This is the server-computed default; it updates as you edit any parameter and the preview on the right is re-rendered too. It also works without JavaScript: fill the form and press Generate.
2. Full parameter table 2 parameters, one per row; scroll sideways on narrow screens.
click the title to collapse / expand
| Parameter | Type | Default | Description |
|---|---|---|---|
component |
string |
required / as needed | Component code for components/{code}.php; a missing file returns an empty string. |
options |
array |
[] | Query options plus component config; items/total/paginator are injected automatically. |
3. Examples Every example can be copied as-is; the later ones are more advanced.
click the title to collapse / expand
Minimal
Start with the component code and a row count to confirm the block renders.
<?= content_block('home-news', ['limit' => 4]) ?>
A featured products section with query options
model, limit, and order drive the query first, and the remaining keys are handed to the component.
<section class="ry-section">
<h2>Featured products</h2>
<?= content_block('home-products', ['model' => 'product', 'limit' => 8, 'order' => 'views desc']) ?>
</section>
In a sidebar, with the heading overridden
A component that is not in any layout can still be called from a template; title is its own option and replaces the default heading.
<aside class="ry-side">
<?= content_block('home-news', ['limit' => 4, 'title' => 'Latest news']) ?>
</aside>
4. What it does / when to use it
Use it for a block built in the admin component library, the kind that carries its own heading and options, when you want that block pinned to a fixed place in a template. It is called by component code and can take the query options in the same call: the tag fetches data first and then hands the result to the component. Do not use it when the order of a whole page is decided in the admin, which is home_blocks, and do not use it to render a single record with no query involved, where render_component is more direct.
home_blocks, and do not use it to render a single record with no query involved, where render_component is more direct.5. Which pages it belongs on This is the question clients actually ask: "I am building the home page / a list page / a detail page — which tags do I use?"
click the title to collapse / expand
| Page | What that page is | What this tag does there |
|---|---|---|
| Home | Home page: hero, category blocks, latest content |
On the home page it usually sits in the hero, a category block, or a latest/featured section. You use it to: Use it for a block built in the admin component library, the kind that carries its own heading and options, when you wan |
| Single pages | One-off pages such as About or Contact |
On a single page (About, Contact) it sits inside the content block. You use it to: Use it for a block built in the admin component library, the kind that carries its own heading and options, when you wan |
Clicking a page name jumps to every tag for that page in the reference (the "By page" filter there). This page always shows everything about the tag, whatever that filter is set to.
6. How to use it (step by step)
- Get the component code first. The identifier shown in the component library, such as
home-news, is the first argument, and it maps to a component file of the same name in the theme pack. A wrong code raises no error; the page simply loses a block.
- Call it with the code alone to confirm the component renders at all:
content_block('home-news'). If nothing appears at this step, the problem is the component, not your query options.
- To control how much data is fetched and in what order, pass the query options as the second argument:
model, limit, order, and category are used to fetch data, while the remaining keys become component configuration.
- Write the component's own options, such as a heading, a column count, or whether badges show, into the same array. The tag removes
model from the configuration and passes everything else through unchanged.
- Use this call when a component is installed but never placed into a layout, or when you only need it in one corner of one page. Inside the component you also get
items, total, paginator, model_code, and category, prepared by the tag.
home-news, is the first argument, and it maps to a component file of the same name in the theme pack. A wrong code raises no error; the page simply loses a block.content_block('home-news'). If nothing appears at this step, the problem is the component, not your query options.model, limit, order, and category are used to fetch data, while the remaining keys become component configuration.model from the configuration and passes everything else through unchanged.items, total, paginator, model_code, and category, prepared by the tag.7. Common pitfalls
- Getting the component code wrong in case or hyphens: nothing is thrown, and the page just misses a block. Check that a component file of that name exists in the pack (
components/ in the current pack, or _shared/components/).
- Assuming it honours the enabled flag in the admin. This tag renders the component by file name, so a component that was disabled in the admin still prints. When you need the enabled flag, default configuration, and config type casting, use
render_component.
- Treating
limit and order as pure configuration. They are query options too, so changing them changes how many rows come back and in what order. If the component reads the same key, the two influence each other and one edit needs checking in both places.
- Assuming the data fetched by the tag is always used. Some block components run their own query, for example to fetch news by their own
limit, and then the items passed in are ignored, so the number of rows on the page comes from the component's own configuration. Check the component notes to see which data it reads.
Note from the reference table It renders by file name (Theme::component) without consulting the component registry: a disabled component still renders, and registry defaults plus schema type casting are not applied.
components/ in the current pack, or _shared/components/).render_component.limit and order as pure configuration. They are query options too, so changing them changes how many rows come back and in what order. If the component reads the same key, the two influence each other and one edit needs checking in both places.limit, and then the items passed in are ignored, so the number of rows on the page comes from the component's own configuration. Check the component notes to see which data it reads.8. Real rendered output This section was rendered once on the server with this site real data; it is not a mock-up.
click the title to collapse / expand
It outputs a whole page region (this site header / footer / a full layout section, or it decides what to render from the current page data). Inside this small box it would just splice another page skeleton into this one: you would not see its real effect, and it would wreck this page. Copy it into your template instead.
Loading the code…
9. Where it already appears in your templates Grouped by components / page templates / template packs; the data comes from a script scan.
click the title to collapse / expand
No call site for this tag in this site templates yet.