JReviews logo
Guides My site
← All guides Community guide

Generate dynamic listing and category headings

Alejandro
Thread started by Alejandro. Contributors Alejandro.
Thread started
Last updated

What you’ll achieve

Customize the visible listing heading while keeping its stored title unchanged.

My site

Platform
JReviews version

Add text to the visible listing heading while keeping the saved listing title unchanged. Check the browser title separately.

Choose the visible heading and document title

Use a listing saved as Lakefront Hotel. With the field example, its visible heading becomes Lakefront Hotel near Lake Michigan. The stored title remains Lakefront Hotel, and the browser title keeps the listing type's SEO format. The fixed-suffix example needs no custom field.

To use a suffix entered on each listing, prepare the field before editing either heading template:

  1. In Setup > Field Groups, create a listing field group named Heading details, or reuse an associated listing group.
  2. In Setup > Fields, create a listing Text field labeled Title suffix. In Name, type titlepostfix; JReviews adds the jr_ prefix, so the field name becomes jr_titlepostfix. Select Heading details as its field group.
  3. Open the listing type used by Lakefront Hotel. In Field Groups, associate Heading details with that listing type.
  4. Keep the field active, optional, and without dependencies. Give listing editors write access and heading viewers read access.
  5. Edit Lakefront Hotel and enter near Lake Michigan in Title suffix. This is text entered by the listing editor. Do not create predefined options.

Use the field name shown above in the template examples, or replace it with your field's exact name.

Check the listing type SEO settings first

Open the listing type's SEO settings. Under Listing Detail Page, review Page Title and Apply to Listing Titles. Use them when the supported replacement tags produce the result you need.

JReviews 6 Early Access

Enable Listing Detail Page in Early Access. Apply to Listing Titles can change the heading visitors see while the browser title still uses the original title in its SEO format. Check the page heading and the browser-tab title separately.

Change only the visible listing heading

If you want a suffix only in the visible heading, copy the listing header template into your overrides folder. Create the missing folders.

Copy components/com_jreviews/resources/views/site/components/listings/detail/header.blade.php to templates/jreviews_overrides/resources/views/components/listings/detail/header.blade.php.

Copy wp-content/plugins/jreviews/resources/views/site/components/listings/detail/header.blade.php to jreviews_overrides/resources/views/components/listings/detail/header.blade.php.

The template contains two heading branches, one with header media and one without. Each has this level-one heading line, so it appears twice in the file. Use your editor's search to find both, and change both. In the blocks below, the line marked with - is the current line, and the line marked with + replaces it.

<x-jreviews::heading level="1" size="3xl" class="fwd-inline">{{ $listing->title }}</x-jreviews::heading>
<x-jreviews::heading level="1" size="3xl" class="fwd-inline">{{ $listing->title }}{{ ' - with a postfix' }}</x-jreviews::heading>

For a value from a custom field, use this line instead:

<x-jreviews::heading level="1" size="3xl" class="fwd-inline">{{ $listing->title }}</x-jreviews::heading>
<x-jreviews::heading level="1" size="3xl" class="fwd-inline">{{ $listing->title }} {{ $listing->getFieldTextString('jr_titlepostfix') }}</x-jreviews::heading>

Use the Title suffix field prepared above. The template displays it as text, so entered characters cannot become HTML formatting. This example adds the suffix to every listing using this header. Limiting it to a category or listing type requires an additional @if condition. Change only the heading expression shown above; keep other uses of the title unchanged so the browser title retains its configured value.

Change only a category's visible heading

Enable Listing List Pages in Early Access for this example. For a fixed category heading, set Page Heading in the category menu's page settings first. To generate a suffix in the template, copy the list page template into your overrides folder. Create the missing folders.

Copy components/com_jreviews/resources/views/site/listings/list.blade.php to templates/jreviews_overrides/resources/views/listings/list.blade.php.

Copy wp-content/plugins/jreviews/resources/views/site/listings/list.blade.php to jreviews_overrides/resources/views/listings/list.blade.php.

Find {!! $headingText !!} inside the level-one heading. Leave that line in place and add the lines marked with + directly below it. The dimmed lines are already in the file.

<x-jreviews::heading level="1" size="3xl" :class="($showHeading ?? true) ? '' : 'fwd-sr-only'">
    {!! $headingText !!}
    @if ($categoryHeader && (int) $categoryHeader->id === 23)
        {{ ' - something or other' }}
    @endif
</x-jreviews::heading>

Replace 23 with your category ID and the suffix with your text. Setup > Categories shows each category's number in the ID column. The condition limits the example to that category. Leave $pageTitle and the rest of the template unchanged. Check the category heading, document title, pagination, and another category after saving.

Compare copied templates with the installed originals after JReviews updates.

JReviews 5 and v6 Legacy

Add text after the listing heading

If the SEO replacement tags cannot express your heading, customize only the visible heading template.

Use Theme Explorer to identify the active template. The standard legacy layout uses listings/detail_header.thtml; the compact layout uses listings/detail_compact.thtml. Copy that file from the distributed theme into the matching location in your active custom theme, using your CMS path below. Replace mysite with your active custom theme name. Preserve the rest of the file.

Use templates/jreviews_overrides/views/themes/mysite/listings/detail_header.thtml.

Use jreviews_overrides/views/themes/mysite/listings/detail_header.thtml.

Find the existing title output inside the visible <h1>. Keep that expression unchanged and append the escaped text immediately after it. For the standard legacy templates, the result is:

<?php echo $this->action == 'detail' ? $Routes->content($listing['Listing']['title'], $listing) : $listing['Listing']['title']; ?><?php echo htmlspecialchars(' - with a postfix', ENT_QUOTES, 'UTF-8'); ?>

If your custom theme uses a different title expression, keep its existing expression and append only the final htmlspecialchars() output. Update the heading branch your layout displays.

Apply this only to the visible heading, leaving other uses of the title alone. For a suffix from a custom field, use the field's first value as the escaped expression:

<?php echo htmlspecialchars((string) ($listing['Field']['pairs']['jr_titlepostfix']['value'][0] ?? ''), ENT_QUOTES, 'UTF-8'); ?>

Add a literal space between the existing title output and this field expression. Replace jr_titlepostfix if you used another field name. Lakefront Hotel then displays Lakefront Hotel near Lake Michigan, while its stored title remains Lakefront Hotel. Only the heading on the page changes; the browser title still uses the saved listing title and its configured SEO format.

JReviews 5 and v6 Legacy category pages

Change the category heading

Use templates/jreviews_overrides/filters/filter_functions.php.

Use jreviews_overrides/filters/filter_functions.php.

Add the separate callback marked with +.

  • If filter_functions.php already exists, add the marked lines at the end of the file. The copy button copies only those lines.
  • If you are creating filter_functions.php, type the two dimmed lines first, then add the marked lines below them.
<?php
defined('MVC_FRAMEWORK') or die;

Clickfwd\Hook\Filter::add('before_theme_render_viewvars', function ($viewVars, $params) {
	if ($params['route'] === 'categories.category') {
		$viewVars['page']['title'] .= ' - something or other';
	}

	return $viewVars;
});

Replace the fixed suffix with your text. The condition limits this change to legacy category headings.

Check the result

Check the visible listing heading and browser title separately. Include a listing whose original title appears in an SEO format. Check both a header with a cover or logo and a header without one. The suffix must appear once in the visible heading, while the document title and saved listing title keep their configured values.

Clear Cache & File Registry after adding override files. Check the category heading and an unrelated page separately. Confirm that changing the text after the visible heading does not change the browser title.

JReviews 5. See the SEO reference for replacement tags.

JReviews 6. See the SEO reference for replacement tags.

See legacy theme overrides for template setup.

Learn more