Welcome to Genhike Sports

Template tag generator

Editing Content List content_list Parameters: model news | limit 10 Page preview: rows 5 → 5length 3180 → 3180 bytes Preview

Home Template tags Every block below has its own preview zone, cut to how that tag is really used — it follows your parameters, and region previews load when you click Preview.

Home: 19 tags · page 1 / 5, 4 tag blocks per page

Content Listcontent_listUsed inside componentsiFetches a list of content items for one model. This is the most used tag: news, product, and case lists all rely on it.PreviewDetails →

scene · List blockcontext: a batch of rows (5)

One block on a list page (these are the 5 rows it fetched)

What you change most on this tagFetch a batch of content (no paging): what you change most is which model, how many rows, and the sort order.

  • Which model to fetchmodeltextdefault news
    <?= content_list(['model' => 'product', 'limit' => 6]) ?>

    Where the implementation reads it core/Tpl.php:456

  • How many rowslimitintdefault 10
    <?= content_list(['model' => 'news', 'limit' => 6]) ?>

    Where the implementation reads it core/Content.php:291

  • Sort orderordertextdefault pinned first
    <?= content_list(['model' => 'news', 'order' => 'views desc']) ?>

    Where the implementation reads it core/Content.php:268

Filters such as category, category_slug, category_in, keyword, exclude, flag and lang sit on the same level. For paging use content_query() plus pager(), do not compute pages here.

rows 5 → 5length 3180 → 3180 bytes

Content Cards (one line)content_cardsiFetches a batch of rows and sets the items per row in one line: internally it equals content_list plus a card component that really exists.PreviewDetails →

scene · List blockcontext: a batch of rows (5)

This is what content_cards itself renders: 5 rows (the card look comes from the card component; the items per row come from the columns parameter of this tag)

A convenience wrapper: the preview renders the tag itself (content_list + the card component), and columns decides the items per row.

What you change most on this tagContent cards (one line does it all): the column count (columns) is this tag own parameter, written into the tag call, not into the host component CSS. Also the card component and the row count.

  • columns (items per row, tag parameter)columnscolumnsdefault 32 to 6 is the usual range; omit it to add no grid styles and let the card component lay itself out

    This is a parameter of the tag itself, not host component CSS: put it in the columns field of the parameter form above, or copy the line below. It only sets the grid columns of the outer container; the card look still belongs to the card component.

    <?= content_cards(['model' => 'news', 'limit' => 6, 'columns' => 3]) ?>

    Where the implementation reads it core/tpl_functions.php:275

  • Which card component renders each rowcardtextdefault omit = looked up in the component registry by model
    <?= content_cards(['model' => 'product', 'card' => 'product-card']) ?>

    Where the implementation reads it core/tpl_functions.php:216

  • How many rowslimitintdefault 10
    <?= content_cards(['model' => 'news', 'limit' => 8]) ?>

    Where the implementation reads it core/Content.php:291

Do not mix up the two paths: this tag column count is the tag parameter columns (it only writes one grid-template-columns onto the outer container, the card look is untouched); content_list and content_query are pure data tags with no column parameter, so their items-per-row can only be changed in the host component CSS.

rows 5 → 5length 4963 → 4963 bytes

Content Blockcontent_blockiRenders one content block component (the orchestrated kind from the component library in the admin) by its code.PreviewDetails →

scene · Layoutcontext: none needed

↓ This block is what content_block() produced

News & Insights

Stay up to date with what we are doing

View All →

What you change most on this tagContent block: pick a component to render it, handing over the model and the row count. What you change most is the component, the model and the row count.

  • Which component to rendercomponenttext
    <?= content_block('home-news', ['model' => 'news', 'limit' => 6]) ?>

    Where the implementation reads it core/Tpl.php:505

  • Which model to fetchmodeltextdefault news
    <?= content_block('home-news', ['model' => 'product']) ?>

    Where the implementation reads it core/Tpl.php:490

  • How many rowslimitintdefault 10
    <?= content_block('home-news', ['model' => 'news', 'limit' => 4]) ?>

    Where the implementation reads it core/Content.php:291

Every key except model is passed to the component as its config; which keys the component reads is defined by its own config_schema, not here.

rows 1 → 1length 5569 → 5569 bytes

Render Componentrender_componentUsed in page templatesiRenders any component by code and lets you pass data into it (lower level than content_block).PreviewDetails →

scene · Layoutcontext: none needed

↓ This block is what render_component() produced

Outdoor gear & camping equipment

Genhike Sports is based in Weihai, Shandong, specializing in inflatable tents, quick-opening tents and air mattresses.

What you change most on this tagRender one component from the component library: what you change most is the component code; pass row data through the third argument.

  • Component codecodetext
    <?= render_component('list-content') ?>

    Where the implementation reads it core/tpl_blocks.php:131

  • Extra template variables (for example hand the current row to a card)datatextdefault []
    <?= render_component('news-card', [], ['item' => $item]) ?>

    Where the implementation reads it core/tpl_blocks.php:131

The second argument is the component config; its keys come from that component config_schema, so look at the component in the library, not at this tag.

rows 1 → 1length 957 → 957 bytes

Common snippets

Whole blocks you can copy in one click.

Page shell

The skeleton every page template needs: head, header, main, footer and scripts.

<!DOCTYPE html>
<html lang="<?= e(Ry\Lang::hreflang()) ?>">
<head>
    <?= tpl_head() ?>
    <?= theme_css() ?>
</head>
<body class="ry-site">
<?= theme_header() ?>

<?= page_layout([
    'main'    => ,
    'sidebar' => ,
]) ?>

<?= theme_footer() ?>
<?= theme_js() ?>
</body>
</html>

List page

A paginated list: content_query() returns the items and the paginator, pager() renders it.

<?php $q = content_query(['model' => 'news', 'page' => max(1, (int)($current_page ?? 1)), 'page_size' => 12]); ?>
<?php foreach ($q['items'] as $item): ?>
    <article class="ry-card">
        <a href="<?= e(content_url($item)) ?>">
            <img src="<?= e(content_thumb($item)) ?>" alt="<?= e(field($item, 'title')) ?>" loading="lazy">
            <h3><?= e(field($item, 'title')) ?></h3>
        </a>
        <p><?= e(content_excerpt($item, 80)) ?></p>
        <time><?= e(content_date($item, 'Y-m-d')) ?></time>
    </article>
<?php endforeach; ?>
<?= pager($q['paginator']) ?>

Detail page

A detail page: title, date, cover and body (the body is already sanitized — do not escape it twice).

<!DOCTYPE html>
<html lang="<?= e(Ry\Lang::hreflang()) ?>">
<head>
    <?= tpl_head() ?>
    <?= theme_css() ?>
</head>
<body class="ry-site">
<?= theme_header() ?>
<?= breadcrumb() ?>

<article class="ry-article">
    <h1><?= e(field($item, 'title')) ?></h1>
    <time><?= e(content_date($item, 'Y-m-d')) ?></time>
    <img src="<?= e(content_thumb($item)) ?>" alt="<?= e(field($item, 'title')) ?>">
    <?= content_body($item) ?>
</article>

<?= theme_footer() ?>
<?= theme_js() ?>
</body>
</html>

Breadcrumb + search + language switcher

The usual inner-page toolbar: breadcrumb, site search (submits to the search page) and the language switcher.

<div class="ry-toolbar">
    <?= breadcrumb() ?>

    <form class="ry-site-search" action="<?= e(url_lang('search')) ?>" method="get" role="search">
        <input type="search" name="q" value="<?= e($keyword ?? '') ?>" autocomplete="off"
               placeholder="<?= e(t('search_placeholder')) ?>" aria-label="<?= e(t('search')) ?>">
        <button type="submit"><?= e(t('search')) ?></button>
    </form>

    <?= lang_switcher(['style' => 'dropdown']) ?>
</div>

Tag FAQ

How do I read a custom field?

Use field($item, 'name'). Custom fields work exactly like built-in ones: once the field exists in the admin you can read it. Wrap the output in e(), otherwise user input can turn into executable script.

Why does my pagination do nothing?

A list page needs content_query(), not content_list(): only the former returns a paginator, which you hand to pager(). Use content_list() when you want a fixed number of items and no paging (its limit caps at 100).

Will Chinese text leak into the English site?

The tag table has an English overlay (core/tpl_tags_en.php) and the English site reads that one, so both languages are complete here. In your own templates keep copy in the language pack or t(); hard-coded Chinese is served as-is on the English site.

How do I limit a list to one category without its children?

content_list(['category' => 12, 'category_in' => true]): category takes a **numeric category id** only, and without category_in you get **that category alone, no children**; pass 'category_in' => true explicitly to include subcategories. If all you have is a slug such as news, do not put it in category (it becomes 0 and you get a silently empty list) — use category_slug instead.

How do I filter by top / featured flags?

Use the flag parameter: top, recommend or hot. The default order already puts pinned items first; use order (whitelisted field names such as id desc or views desc) to change it.

Which tags exist, and how do I know they match the core?

This list is not hand-copied: it is scanned from the core template API surface (core/tpl_functions.php, core/tpl_blocks.php), so a tag added in code but missing here fails the check. After changes run php cli/check-tags.php: it verifies that every tag in code is documented, that every documented tag exists, and that the front-end page renders them all.

Send an Enquiry