1

Is there a way to create a custom model/view for an existing component? For instance, if you wanted to change the Query used in com_content to include data from other tables when looking at a Category, is it possible to create a new modal/view to make this happen? Or if one wanted to integrate other types of content (like using the twitter api or tumblr api) to put contentment in the category flow (and maintain the correct pagination) it would require change the model, but can a custom modal be created without hacking the Joomla core?

thanks!

David Barratt
  • 546
  • 1
  • 6
  • 24

3 Answers3

1

When creating content we have written a plugin which executes onAfterContentCreate in this plugin we have written custom model functionality. This plugin gets called when all the default functionality have executed. We have modified the view in our template, In template html folder we have written extended view.

sushil bharwani
  • 29,685
  • 30
  • 94
  • 128
  • "onAfterContentCreate" is not a valid Joomla! function, unless you have a link to the documentation on that function. thanks! – David Barratt Aug 16 '11 at 15:17
  • 'onAfterContentCreate' isn't a function as such, it's an event. Plugins hook these events, and anything (in this case a core 'com_content' component model) can use JDispatcher to dispatch them. – KingJackaL Sep 06 '11 at 03:03
1

joomla doesn't provide any feature to create custom model or view of an existing component. you can override a view using template overriding but it will only change the look of the page but not the functionality..

Anand
  • 1,670
  • 1
  • 15
  • 23
0

As sushil bharwani pointed out, probably best option is to create Content plugin and hook up the event onAfterContentCreate (see available events for content plugins).

It's also possible to use components models for your own extension as you initially intended. This method has been used in Joomla CMS 1.7 itself (mod_articles modules load content component model in own helper files), similar as described in great article here: Joomla MVC – Load a model from anywhere!.

I can confirm this works fine, but evaluate which option is better for your project as component models are made primarily for Joomla's native components and may lack some specific functionality.

piotr_cz
  • 8,755
  • 2
  • 30
  • 25