Welcome to Genhike Sports

Field Parameter Table

← Back to the tag reference

Hand-written Includes in-depth notes

Field Parameter Table content_fields Used inside components 8 host files / 8 calls

Renders the custom fields of one content item as a parameter table / definition list; the specification table on a product page is exactly this.

content_fields($item, array $options = [])

Pages List pages Detail pages Single pages

Used in
List pages / Detail pages / Single pages
Defined in
core/tpl_functions.php:352
Core method
Tpl::fields()
How do I read these repository paths?

All paths are relative to the site root. Open core/tpl_functions.php at line 352 to see the definition of content_fields(). 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
Content row; without _model_id it renders nothing.
The whole options array (advanced): merged with the sub-keys below via array_merge(whole array, ['sub-key' => value]), and a sub-key wins on a name clash. Normally use the sub-keys instead.
Allow-list: show only these fields. The key the implementation reads is fields, not only (core/Tpl.php:877). Write an array literal such as ['model_no','brand']; a single field name also works (the implementation wraps it in (array)). Do not write a comma-separated string - it becomes one element, ['a,b']. An explicit allow-list also bypasses the hide-on-detail-page flag.
Skip these fields (matched against the admin field name such as price, not the visible label). Write an array literal such as ['price','stock']; a single field name also works. Do not write a comma-separated string (core/Tpl.php:878).
Layout: list for a definition list (default) or table for a parameter table. The table layout already emits the full table markup, so do not wrap it in another table (core/Tpl.php:879).
Replaces the default ry-fields class, for example ry-specs; the table layout also adds ry-fields-table (core/Tpl.php:958).
Generated code

Now generating: content_fields

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 6 parameters, one per row; scroll sideways on narrow screens.

click the title to collapse / expand
Parameter Type Default Description
item array required / as needed Content row; without _model_id it renders nothing.
options array [] The whole options array (advanced): merged with the sub-keys below via array_merge(whole array, ['sub-key' => value]), and a sub-key wins on a name clash. Normally use the sub-keys instead.
fields array [] (all fields) Allow-list: show only these fields. The key the implementation reads is fields, not only (core/Tpl.php:877). Write an array literal such as ['model_no','brand']; a single field name also works (the implementation wraps it in (array)). Do not write a comma-separated string - it becomes one element, ['a,b']. An explicit allow-list also bypasses the hide-on-detail-page flag.
exclude array [] Skip these fields (matched against the admin field name such as price, not the visible label). Write an array literal such as ['price','stock']; a single field name also works. Do not write a comma-separated string (core/Tpl.php:878).
layout string list (definition list) Layout: list for a definition list (default) or table for a parameter table. The table layout already emits the full table markup, so do not wrap it in another table (core/Tpl.php:879).
class string ry-fields (default) Replaces the default ry-fields class, for example ry-specs; the table layout also adds ry-fields-table (core/Tpl.php:958).

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

click the title to collapse / expand

Minimal

One line produces the whole specification table, already carrying the ry-fields and ry-fields-table classes.

<div class="ry-specs"><?= content_fields($item, ['layout' => 'table']) ?></div>

Guard, then wrap in a card

Price and stock are already rendered next to the main image, so they are excluded here; the emptiness check keeps an empty card off the page.

<?php $ryFieldsHtml = (string)content_fields($item, ['layout' => 'table', 'exclude' => ['price', 'stock']]); ?>
<?php if ($ryFieldsHtml !== ''): ?>
    <section class="ry-specs">
        <h2>Specifications</h2>
        <?= $ryFieldsHtml ?>
    </section>
<?php endif; ?>

Allow-list with a custom class

Keeps model number, brand, and MOQ only, and swaps in the theme class so the block can be styled on its own.

<?php $ryFieldsHtml = (string)content_fields($item, [
    'fields' => ['model_no', 'brand', 'moq'],
    'layout' => 'table',
    'class'  => 'ry-specs',
]); ?>
<?php if ($ryFieldsHtml !== ''): ?>
    <?= $ryFieldsHtml ?>
<?php endif; ?>

4. What it does / when to use it

Use it for the specification block on a product detail page, the fact table on a case study, or the attributes of a downloadable file. It renders every custom field of one content row that is meant for visitors, either as a definition list or as a table, with labels taken from the current language and units and option text already resolved. Do not use it when the design needs per-field markup or a single value; call field() or field_text() instead. It never prints core columns such as title, summary, views, or publish time.

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 the specification block on a product detail page, the fact table on a case study, or the attributes of a down
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 the specification block on a product detail page, the fact table on a case study, or the attributes of a down
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 the specification block on a product detail page, the fact table on a case study, or the attributes of a down

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. Pick the layout first. The default builds a dl definition list, which suits a sidebar fact block; pass ['layout' => 'table'] for a specification table, which already emits the full table markup with th and td cells, so do not wrap it in another table.
  2. Exclude anything you rendered elsewhere, for example content_fields($item, ['exclude' => ['price', 'stock']]) on a product page whose price and stock sit next to the main image; otherwise the same data shows up twice.
  3. Use the allow-list to print a short set, for example ['fields' => ['model_no', 'brand', 'moq'], 'layout' => 'table']. An explicit allow-list also bypasses the hide-on-detail-page flag, so decide yourself which fields belong there.
  4. Test the result before wrapping it in a card. The tag returns an empty string when there is nothing to show instead of raising an error, so guard with if ($ryFieldsHtml !== '') to avoid an empty box.
  5. Pass ['class' => 'ry-specs'] when the theme needs its own hook. It replaces the default ry-fields class, and the table layout still adds ry-fields-table, so a single .ry-specs rule is enough.

7. Common pitfalls

  • Treating an empty result as a failure. When every field is empty, when the fields are flagged to stay off the detail page, or when the row has no _model_id, the tag returns an empty string without any error and the page simply loses its specification block. Check the field values in the admin panel first, then confirm the row came from content_list().
  • Using the wrong allow-list key. This version reads fields, so writing only is ignored silently and the full set is still printed, which makes the filter look broken.
  • Passing a field label to exclude. It matches the field name from the admin panel, such as price, not the visible label.
  • Expecting core columns. Title, summary, body, views, and publish time live outside the custom field list and never appear in this table; print them in the template with field() when the design needs them.
  • Calling it on a page whose editor body already contains a specification table. The same data appears twice, so narrow the output with exclude or fields until only one copy remains.

Note from the reference table The documented example calls fields(), which does not exist in templates and causes a fatal error; write content_fields($item, ['layout' => 'table']). Core fields (title, summary, body, thumb) never appear in the table, and empty values are skipped.

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

  • templates/_shared/components/detail-content-case.php ×1 lines 138
  • templates/_shared/components/detail-content-download-table.php ×1 lines 519
  • templates/_shared/components/detail-content-download.php ×1 lines 519
  • templates/_shared/components/detail-content-partner-cases.php ×1 lines 227
  • templates/_shared/components/detail-content-partner-profile.php ×1 lines 208
  • templates/_shared/components/detail-content-partner.php ×1 lines 211
  • templates/_shared/components/detail-content-product.php ×1 lines 140
  • templates/_shared/components/detail-content.php ×1 lines 55

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 13 of 56.

click the title to collapse / expand
Send an Enquiry