Hand-written Includes in-depth notes
Model Name model_name
Used inside components
Display the model name in the current language, for example news -> News Center.
model_name($code, $fallback = '')
Pages List pages Detail pages
How do I read these repository paths?
All paths are relative to the site root. Open core/tpl_functions.php at line 345 to see the definition of model_name(). 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: model_name
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 |
|---|---|---|---|
code |
string |
required / as needed | Model code such as news or product; a numeric id never matches. |
fallback |
string |
'' | Used when the model is unknown; by default the code itself is returned. |
3. Examples Every example can be copied as-is; the later ones are more advanced.
click the title to collapse / expand
Minimal
The heading reads the registered name for the current language, so the template never changes between sites.
<h1 class="ry-page-title"><?= e(model_name('product')) ?></h1>
List page using the model code variable
The code is already in a variable on list pages, and the fallback keeps an empty heading off the page.
<?php $ryModelName = (string)model_name($model_code, 'Content'); ?> <h1 class="ry-page-title"><?= e($ryModelName) ?></h1>
Type badge in search results
Search results mix models, so the badge must resolve the name from each row's own model code instead of showing one name everywhere.
<?php $ryCode = isset($result['_model_code']) ? (string)$result['_model_code'] : ''; ?> <span class="ry-badge"><?= e(model_name($ryCode, 'Content')) ?></span>
4. What it does / when to use it
Use it for a page heading, the type badge on a search result, a filter dropdown, or a breadcrumb entry that names a model such as News Center. It returns the registered name for the current language, so the English site reads the English name and a rename only has to happen once. It covers model display names only: category names come from category rows and field names are a separate concern, so do not mix them.
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 |
|---|---|---|
| List pages | Category list pages: listing, filters, pagination |
On a list page it lives in the list container or right next to the pagination bar. You use it to: Use it for a page heading, the type badge on a search result, a filter dropdown, or a breadcrumb entry that names a mode |
| Detail pages | Content detail pages: body, specs, related items |
On a detail page it goes in the body area or in the related-items sidebar. You use it to: Use it for a page heading, the type badge on a search result, a filter dropdown, or a breadcrumb entry that names a mode |
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)
- Pass the model code, for example model_name('product'), and the tag returns the name registered for the current language.
- The model code is the lowercase identifier from the admin model list, such as news or product, not the name shown on the page, so a typo resolves to nothing.
- In a list template the code is usually already in a variable, so call model_name($model_code, 'Content') and use the second argument as the fallback.
- Always supply that fallback. When a model was deleted or the code is wrong, the tag prints the fallback, or the raw code when no fallback is given, which is easier to notice and easier to debug than a blank heading.
- Wrap the output in e(), and when the name becomes the page heading keep a single top-level heading on the page instead of adding a second one in the body.
7. Common pitfalls
- Hard-coding a name in the template: the English site then prints the other language untouched. Resolving by model code lets each language read its own name.
- Using the model name stored on the content row as the display name. That string is written while the list is assembled, and the value on a single page is often a fixed name that stays untranslated; querying the registry by code is what returns a localized name.
- Getting the case or the spelling wrong. Model codes are lowercase identifiers, so a capitalized or hyphenated variant resolves to nothing and the page prints the fallback or the raw code.
- Using it for category or field names. It only reads the model registry, while categories and fields have their own sources, so mixing them yields empty output or a raw code.
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
A model code turned into the model name from the admin (in the current language).
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
Components 8 files / 9 calls 89% of tag calls live in components
-
templates/_shared/components/search-results-grouped.php×2 lines 124, 436 -
templates/_shared/components/list-advantages-icons.php×1 lines 101 -
templates/_shared/components/list-advantages-rows.php×1 lines 95 -
templates/_shared/components/list-advantages-stats.php×1 lines 151 -
templates/_shared/components/list-jobs-table.php×1 lines 409 -
templates/_shared/components/search-results-cards.php×1 lines 332 -
templates/_shared/components/search-results-empty.php×1 lines 595 -
templates/_shared/components/search-results.php×1 lines 89
Click "See this code + preview": the left shows the real code around that call site (±12 lines, call line highlighted) and the right renders a real page preview with the current parameters.