I am using the Joomla Search module with a Menu Item pointed to '/search'. When a search is performed, the results list a linked title, a snippet, category and the created date.

The snippet is mostly good but sometimes they are very strange and begin with '...'. I checked the results array and it does not return the fulltext of the article so there is no way to apply my own string truncate function. Here is a sample output:

<dl class="search-results">
    <dt class="result-title">
        1. <a href="/foo-bar">Foo Bar Title</a>
    <dd class="result-text">
        ...&nbsp;, lorem ipsum text ipsum lorem: Lorem Ipsum orem ipsum dolor sit amet, consectetur adipiscing elit....
    <dd class="result-created">
        Created on 26 June 2017 </dd>

Most of the snippet output is pretty much as I expected. I checked the 'Search - Content' plugin and it is returning the full Article details.

Is this an expected behaviour as it seems like a bug to me and is there a way without having to write custom plugins to either get the fulltext if this is an expected behaviour?


1 Answer 1


That's a valid question in terms of questioning where the string is split and how someone could adjust the length of the article text in the search results. The solution is fairly simple at the end.

How things work:

  • The overall concept of the search regarding the article's text, is to return a cleaned part of the string, around the search term, which is highlighted inside the rest of the string. This is how it is designed.

  • There is a default limit set for this, that is 200 characters.

  • This is why, sometimes you see the text starting with '...', as it means to denote that this isn't the start of the text of the article returned in the search results.

How the article's text ending up split:

  • You are correct. The article's text is coming full from the query to the database that is called by the content search plugin. It reaches like this up to the com_search search view, view.html.php file.

  • However, just before it takes its route to the default_results.php template for printing out to the screen, it passes through some special processing.

    ~line #273 on view.html.php

     $result->text    = JHtml::_('content.prepare', $result->text, '', 'com_search.search');

  • What this line does:

    It envokes the com_search's SearchHelper class (administrator/components/com_search/helpers/search.php) and the text is going through a number of functions, that manipulate it, starting with the prepareSearchContent().

    Things, however become more interesting as in the way there is a call to another SearchHelper's method - _smartSubstr(), - this is the one that splits the string - which calculates what the final length of the text should be using a JLanguage method. The method is called: getSearchDisplayedCharactersNumber and according to its API documentation it should return the number of characters displayed in search results - INTEGER - The number of characters displayed (200 if no value was set for a specific language).

Where you can set the SearchDisplayedCharactersNumber:

All you need to do is to create an override in languages/overrides of the xx-XX.localise.php for each of the languages you want to adjust this number. The xx-XX.localise.php can be found inside the relative xx-XX language folder.

There you can find the getSearchDisplayedCharactersNumber() method.

public static function getSearchDisplayedCharactersNumber()
    return 200;

Adjust it to suit your needs.


The following resource might be helpful:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.