Welcome to Genhike Sports

Documentation Root URL

← Back to the tag reference

Hand-written Includes in-depth notes

Documentation Root URL docs_root_url Used inside components 6 host files / 6 calls

Resolve a URL inside the documentation category, which may be named help, docs, manual, or guide on different sites; the correct one is detected automatically.

docs_root_url($path = '', $lang = null)

Pages Site-wide (system) List pages Detail pages

Used in
Site-wide (system) / List pages / Detail pages
Defined in
core/tpl_functions.php:484
Core method
(no X::y() forwarding call detected)
How do I read these repository paths?

All paths are relative to the site root. Open core/tpl_functions.php at line 484 to see the definition of docs_root_url(). 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
Relative path inside the docs category; falls back to help/ when no docs category exists
Language code; empty means the current language when looking up the docs category
Generated code

Now generating: docs_root_url

Real page previewOpen in new window

This is the real rendering of the page (real header, container, this tag output, real footer). It reloads when you change a parameter.

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
path string '' Relative path inside the docs category; falls back to help/ when no docs category exists
lang string Current language Language code; empty means the current language when looking up the docs category

3. Examples Every example can be copied as-is; the later ones are more advanced.

click the title to collapse / expand

Smallest link

The smallest form: one relative path and escaped output.

<a class="ry-btn" href="<?= e(docs_root_url('getting-started/')) ?>">Installation guide</a>

Documentation sidebar

A documentation sidebar: the root call covers the index and the other two point at subcategories.

<?php
$docs  = docs_root_url();
$guide = docs_root_url('getting-started/');
$faq   = docs_root_url('troubleshooting/');
?>
<ul class="ry-docs-nav">
    <li><a href="<?= e($docs) ?>">Documentation home</a></li>
    <li><a href="<?= e($guide) ?>">Install and deploy</a></li>
    <li><a href="<?= e($faq) ?>">Troubleshooting</a></li>
</ul>

Another category, or a pinned language

Two escape hatches: category_link() when the built-in slug order picks the wrong category, and the lang argument when the link has to cross languages.

<?php
/*
 * docs_root_url() matches help before docs, so a site that runs both needs
 * category_link() to address the other one explicitly. The second argument
 * pins the language when a link must always open the English documentation.
 */
$devDocs = category_link('docs', 'docs/getting-started/');
$enGuide = docs_root_url('getting-started/', 'en');
?>
<a href="<?= e($devDocs) ?>">Developer documentation</a>
<a href="<?= e($enGuide) ?>">English guide</a>

4. What it does / when to use it

Use it for every link that points into the documentation or help site: home page calls to action, a read-the-manual button on a product page, the more-questions link under an FAQ block, the sidebar documentation nav, and cross-language documentation entries. It exists because the documentation category is called help, docs, manual or guide depending on the site, and hard-coding one of those names produces a 404 on the next site. Scope: it resolves the category URL only and never checks that the target document exists, so a mistyped path still renders fine and the 404 shows up after the click. When the target must exist, build the link from a content query or the category tree instead.

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: Use it for every link that points into the documentation or help site: home page calls to action, a read-the-manual butt
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 every link that points into the documentation or help site: home page calls to action, a read-the-manual butt
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 every link that points into the documentation or help site: home page calls to action, a read-the-manual butt

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)

  1. Decide which level the link belongs to. Call docs_root_url() with no arguments for the documentation home, and pass the relative path for a subcategory or a single page, for example docs_root_url('getting-started/'). A leading slash is accepted and trimmed.
  2. Keep path inside the documentation category and leave the category slug out. docs_root_url('help/getting-started/') resolves to /help/help/getting-started/, with the category segment repeated.
  3. Assign the URL to a variable and escape it with e() like any other template URL instead of printing it raw inside href.
  4. When a site runs both help and docs and you specifically need docs, switch to category_link() and name the slug. docs_root_url() walks help, then docs, manual and guide, so help always wins the match.
  5. Pin the language with the second argument on multilingual sites, for example docs_root_url('getting-started/', 'en'). The current language is used when it is omitted, so cross-language entries must pass it.

7. Common pitfalls

  • Expecting an error when the documentation category is missing. The function falls back to the default /help/ path, so a site without a help category ships a silent 404. Click these links before going live, or create the category first.
  • Passing the category slug inside path. The value is appended as-is, which repeats the category segment and leaves a URL that keeps working only until somebody renames the slug.
  • Assuming it points at docs when the site runs both help and docs. The loop order is fixed and help is matched first, so use category_link() to name the other slug.
  • Passing an absolute site URL such as https://example.com/help/ as path. Only the leading slash is trimmed, so the concatenation produces a malformed address. Relative paths are the only supported input.
  • Assuming the path gets URL-encoded. It does not, so encode directory names that contain spaces or non-ASCII characters, for example %E4%B8%AD%E6%96%87/, before passing them in.

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 needs a real page context (a category, a content row, the current page) before it can produce anything; called on its own it returns an empty value or a URL pointing at this page. Rendering that would teach you nothing — copy it into a real page (a list or detail template).

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 6 files / 6 calls 89% of tag calls live in components

  • templates/_shared/components/hero-center-trust.php ×1 lines 50
  • templates/_shared/components/hero-software.php ×1 lines 32
  • templates/_shared/components/home-cta.php ×1 lines 17
  • templates/_shared/components/home-docs-tree.php ×1 lines 24
  • templates/_shared/components/home-release.php ×1 lines 143
  • templates/_shared/components/list-faq.php ×1 lines 66

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.

11. Previous / next In group order; this is tag 8 of 56.

click the title to collapse / expand

At a glance

docs_root_url

Site-wide (system) / List pages / Detail pages

← Back to the tag reference

Send an Enquiry