User Rating: 5 / 5

Star Active Star Active Star Active Star Active Star Active
 

Whatever it is your reason, sometimes you need to change things on how the components output your information in Joomla. The easiest way is doing a hack into the code, however easy is not always the correct way. Hacking the code (doing changes to the PHP files) is not upgrade safe, the next time Joomla publishes an update, your changes are gone for good.

You could do this with a template override as well, but modification would be tied to the template. Since the template I am not using doesn't override the com_content component, I did the call to do it this way.

Cloning the Component View

The first step is finding the component view you want to alter. In my case, I want to modify the way the article links are done. In this case, things are in the components/com_content/views/article/tmpl directory. You will find at least two files: default.php and default.xml. I have also found the default_links.php file. As my readings, files with an underscore are templates of the views. In my very specific need, what I needed to modify was in defaullt_lniks.php file, but to make this the right way, we need to clone the layout, later we will modify it. Do the following:

  1. Copy the files with a new name, default.php to trusty.php, default.xml to trusty.php and, default_links.php to trusty_links.php
  2. Edit trusty.xml and look for the layout tag. Modify the attributes of that tag. Like this:
    <layout title="com_content_article_view_trusty_title" option="com_content_article_view_trusty_option">
    Take note of those labels as you will need them.
  3. Edit the language and create a language override.
    COM_CONTENT_ARTICLE_VIEW_TRUSTY_TITLE = trusty
    COM_CONTENT_ARTICLE_VIEW_TRUSTY_TITLE = Trusty
    The override must be at least for the backend (site). Beware of the case, it is important.
  4. Flush the cache

After that, do the modifications in the new files as you wish.

Applying the Cloned Component View

At this point, your modification is ready but it is not applied. Do the following:

  1. Edit the articles settings and select your new layout
  2. Edit your already existing menus and select the new layout
  3. Flush the cache

Good luck!

blog comments powered by Disqus