Hand-written Includes in-depth notes
Site Header theme_header
Used in page templates
Outputs the site header with the info bar, the LOGO row, and the navigation, styled by Header Style under Template Settings in the admin.
theme_header(array $config = [])
Pages Site-wide (system)
How do I read these repository paths?
All paths are relative to the site root. Open core/tpl_functions.php at line 26 to see the definition of theme_header(). 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: theme_header
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.
3. Examples Every example can be copied as-is; the later ones are more advanced.
click the title to collapse / expand
Minimal
One line after the body tag, and it must come before any page content.
<body class="ry-site"> <?= theme_header() ?>
Common: handing over to the page body
Opening main right after the header marks the boundary between site chrome and page content.
<body class="ry-site">
<?= theme_header() ?>
<main class="ry-main" id="ry-main">
<h1><?= e($item['title']) ?></h1>
</main>
Advanced: where it sits in a full page skeleton
Header right after the body tag, footer and scripts at the very end: the skeleton every page template shares.
<!DOCTYPE html>
<html lang="en">
<head>
<?= tpl_head() ?>
<?= theme_css() ?>
</head>
<body class="ry-site">
<?= theme_header() ?>
<main class="ry-main" id="ry-main">
<h1><?= e($item['title']) ?></h1>
</main>
<?= theme_footer() ?>
<?= theme_js() ?>
</body>
</html>
4. What it does / when to use it
Call it once directly after the opening body tag on every page template. It renders the logo, the main navigation, the search box, the language switcher and the hotline row, and the navigation highlights the branch of the current category on its own. Do not call it from a component partial, because components are building blocks a layout can place anywhere and a second header would appear in the middle of the page. When a layout scheme renders the page, the header comes from the header block of that scheme, and the layout template falls back to this tag only when the scheme has no header block. The design itself is chosen in the admin under Template Settings, Header Style, or declared by the template pack in theme.json, so changing the header is an admin task rather than a template edit.
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 |
|---|---|---|
| Site-wide (system) | Header, footer, head, styles and scripts — every page template needs them |
It is a system tag written once per page template, inside the page shell (head, header, footer, scripts). You use it to: Call it once directly after the opening body tag on every page template |
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)
- Put
<?= theme_header() ?> on the first line after the opening body tag, so the header renders before any page content. Output that comes first pushes the navigation down and makes the browser jump once the page finishes loading.
- Open the main element right after the header and give it an id, conventionally ry-main, so the breadcrumb, the in-page anchors and any skip link have a stable target.
- Close the page in a fixed order: content, then theme_footer(), then theme_js(), then the closing body and html tags. Keep the roles of the footer and the scripts separate instead of reshuffling the order.
- To change the header design, pick a component under Template Settings, Header Style. A pack that wants one header everywhere declares it in the chrome section of its own theme.json, while a choice made in the admin still wins.
- Self-check the rendered page for the header element: it must appear exactly once. A header block inside a layout scheme plus a call from the template is the usual source of two headers.
<?= theme_header() ?> on the first line after the opening body tag, so the header renders before any page content. Output that comes first pushes the navigation down and makes the browser jump once the page finishes loading.7. Common pitfalls
- Calling it inside templates/*/components/*.php: a component can be placed anywhere by a layout, so the page ends up with a second header or with a header in the middle of the content. Call site chrome from page templates only.
- Printing two headers on one page, either by calling the tag twice or by rendering a header component and then calling this tag: the visitor scrolls halfway and meets the same navigation again. Keep exactly one call.
- Wrapping the output in another container: the header component already emits its own width container and padding, so the extra wrapper double-indents it and a full-bleed background can no longer reach the viewport edges.
- Expecting a class-name change in the template to restyle the header: the component is chosen by the admin setting or by the pack chrome declaration, and the template has no switch for it. This is exactly how a reported replacement that looked applied in the admin fails to show on the front end, and it sends debugging in the wrong direction.
- Letting the home page and inner pages diverge: the home page is not rendered by a layout scheme and only reads the setting, while list and detail pages take their header from their own scheme blocks. Unify both through the admin setting or through a pack chrome declaration.
Note from the reference table The only key the options array reads is component: name the header component to use (core/Tpl.php:194); without it a four level fallback decides.
component: name the header component to use (core/Tpl.php:194); without it a four level fallback decides.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
Page templates 17 files / 17 calls
-
templates/_shared/404.php×1 lines 17 -
templates/_shared/detail.php×1 lines 94 -
templates/_shared/feedback.php×1 lines 33 -
templates/_shared/home.php×1 lines 37 -
templates/_shared/layout.php×1 lines 118 -
templates/_shared/list.php×1 lines 146 -
templates/_shared/member.php×1 lines 58 -
templates/_shared/member_auth.php×1 lines 28
Template packs 2 files / 2 calls
-
templates/official/detail_pkg.php×1 lines 43 -
templates/official/home.php×1 lines 28
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.
Common combinations (generated from your real templates)
- The page template hosting this tag is 404
templates/_shared/404.php
templates/_shared/404.php