3

What is the best way of adding a new view to an existing (built-in or 3rd party) component?

In the particular case I want to add a better tag view to com_tags. The view in com_tags just lists the titles of the items tagged with each item linked to the item view in its own component. I would like the list to also show which component the item belongs to, and optionally some other fields (eg a category, other tags assigned to the item, a truncated description and a date) if the fields exist for that item.

This requires more than a simple view template override as it will change the model and the view xml file. In effect I am asking how to override the model for a component without editing the core file as if the model had the required info then a simple template override would suffice.

Is the only way to achieve this to write a complete new component containing the view?

1 Answer 1

4

There are multiple ways to add functionality or output views to existing components.

  1. You could try a template override. If you need more data then available in the component's model, then you could create your own model that you put in the template override folder, and instantiate your own model in an template override. It's not really the best practice to put a model in the template override folder but IMHO better then a core hack :-)

  2. A better method it to write a plugin (content or system) to enhance the data from the com_tags model with extra information. And create a template override to display that extra information.

  3. Finally you could program your improvements in the component itself and create a PR (Pull Request) that you submit to the Joomla project. However, you are doing it for Joomla 3. There won't be any new features in the Joomla 3 series, only bug fixes (till August 2022) and security fixes (till August 2023). You might try to create a PR for Joomla 4 though.

I would opt for method 2: a plugin to get the extra data in combination with a template override to display the extra data.

4
  • Thanks, I wasn't aware of the possibility of including a new model in the template override folder - for a one-off site requirement I think I prefer this to 2.
    – RogerCO
    Jul 11 at 20:52
  • The advantage of J3 running out of official development is that the time is coming (in a month or so) when it is worth cloning J3 and then making whatever core changes I want without fear of a future new version overwriting them. That's my plan anyway, I already have several useful core hacks implemented in plugins or overrides and it'll be nice to fold them all in. I'll be sticking with J3+ for all my sites for the foreseeable future as life is too short to migrate them.
    – RogerCO
    Jul 11 at 20:56
  • @RogerCO will you also be auditing J3 for security vulnerabilities?
    – Sharky
    Jul 13 at 8:05
  • Nope. My sites are low traffic, low value, non-commercial, no logins, no visitor input, and in some cases not connected to the internet. If someone wants to waste their time fiddling with them for strange purposes so be it.
    – RogerCO
    Jul 14 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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