Remove or Hide  full text or intro text in category blog view

This blog post will teach you how to remove or hide full text or intro text in the category blog view in Joomla using a template override. This method is more complex than using the Joomla article editor, but it gives you more control over how the full text or intro text is removed or hidden.

Prerequisites

To follow this blog post, you will need to have the following prerequisites:

  • A Joomla website
    A basic understanding of HTML and PHP

Steps

To remove or hide full text or intro text in the category blog view in Joomla using a template override, follow these steps:

  1. Create a new folder in the templates/[YOUR_TEMPLATE]/html/com_content directory.
  2. Name the folder category.
  3. Copy the blog.php file from the /templates/[YOUR_TEMPLATE]/html/com_content/categories directory into the new category folder.
  4. Open the blog.php file in a text editor.
  5. Make the necessary changes to the file to remove or hide the full text or intro text.
  6. Save the file.
  7. Clear the Joomla cache and reload the category blog view.

Example
The following code shows how to remove the full text from the category blog view:

<?php

// Remove the full text from the category blog view.
if (isset($this->item->fulltext)) {
    unset($this->item->fulltext);
}

?>


The following code shows how to hide the intro text from the category blog view:

<?php

// Hide the intro text from the category blog view.
if (isset($this->item->introtext)) {
    $this->item->introtext = '';
}

?>


You can also use a template override to remove or hide specific parts of the full text or intro text. For example, the following code shows how to remove the first paragraph of the full text:

<?php

// Remove the first paragraph of the full text from the category blog view.
if (isset($this->item->fulltext)) {
    $fulltext = preg_replace('/<p>(.*?)<\/p>/s', '', $this->item->fulltext);
    $this->item->fulltext = $fulltext;
}

?>


You can use similar code to hide other specific parts of the full text or intro text.

Tips

Here are a few tips for using template overrides to remove or hide full text or intro text in the category blog view in Joomla:

  • Be sure to back up the original blog.php file before making any changes.
  • If you are not comfortable editing HTML and PHP, you can consult with a Joomla developer for assistance.
  • Once you have made your changes to the blog.php file, be sure to clear the Joomla cache and reload the category blog view to see your changes.

Conclusion

Using a template override is the most flexible and powerful way to remove or hide full text or intro text in the category blog view in Joomla. By following the steps in this blog post, you can easily customize the category blog view to suit your needs.