I18N Search - Custom Rendering

By specifying a component name as parameter to the search call, you can render the search result in a different way, e.g.

(% searchresults tags=products component=renderproduct %)

In the component you have access to the following variables:

  • $item: the page or other item found: the properties and methods accessible by $item->propname include:
    • tags (array of strings),
    • title and content,
    • pubDate and creDate (publishing and creation date, both as UNIX timestamps),
    • any custom fields
    • getExcerpt($text, $length): returns an excerpt of $text in the requested $length

  • $showLanguage: true, if the language should be shown
  • $showDate: true, if the date should be shown
  • $dateFormat: date format for strftime
  • $numWords: the number of words requested in the excerpt

A component rendering the page in the default way would look like:

<h3 class="search-entry-title">
  <?php if ($showLanguage) { ?>
  <span class="search-entry-language">
    <?php echo htmlspecialchars($item->language, ENT_NOQUOTES); ?>
  <?php } ?>
  <a href="<?php echo $item->link; ?>">
    <?php echo htmlspecialchars($item->title, ENT_NOQUOTES); ?>
<?php if ($showDate) { ?>
<div class="search-entry-date">
  <?php echo strftime($dateFormat, $item->pubDate); ?>
<?php } ?>
<div class="search-entry-excerpt">
  <?php echo $item->getExcerpt($item->content, $numWords); ?>


Here is an example of rendering the special pages for software with a component, whereas normally they would be rendered like here.