Dean
Dean

Reputation: 8065

Joomla 3 Template override a plugin

I could not find any info on overriding a Joomla plugin in my template. Some forums claimed there was no plugin override, and the Joomla documentation (being the menacing forest that it is) either has nothing on the subject, or the page is hard to find.

So how can we override the output of a Joomla plugin in the same was we override the output of com_content or mod_contact?

Upvotes: 5

Views: 10006

Answers (5)

Lazaros Kosmidis
Lazaros Kosmidis

Reputation: 749

In joomla 3 you can override plugins output only, that's why the origin plugin must be implemented with a tmpl. The naming convention of the folder in you [template]/html is

plg_[type*]_[pluginElement]

Template overridden native joomla plugins is only the pagenavigation.

type* : obviously there's no sense to be other than content but if it's custom plugin no one can stop you.

Upvotes: 6

Dan Knauss
Dan Knauss

Reputation: 11

Elin's answer is not quite correct for Joomla 2.5-3.x. Some plugins do render screen output and have /tmpl folders that you may be able to override. See http://docs.joomla.org/Layout_Overrides_in_Joomla

In some cases you may need to create alternative views within the plugin /tmpl folder. For example, some of the simple, newer custom content components that use JForms let you add fields to com_content articles and select a view template for each field. Then overrides for com_content are generated dynamically to display the custom fields. Each field type can be displayed in the component area through plugins, or in a module, or within the template code, but it will use the /tmpl file you selected for the field in the CCK component. If there is a way to override the different field views from within the template folder, it must require an arcane menu structure I haven't been able to discover.

Upvotes: 1

nhartsog
nhartsog

Reputation: 45

On a Joomla 3.1 install, I am using the Simple Image Gallery plugin and I felt the need to override it in order to add extra functionality to each thumbnail of the gallery.

I copied all of the contents of <joomla_homefolder>/plugins/content/jw_sig/jw_sig/tmpl/ into the folder <joomla_homefolder>/templates/protostar/html/jw_sig/ and I was then able to modify both the default.php file for output modifications, and the accompanying template.css file for styling modifications. This successfully overrides the plugin's output without risking issues during future updates.

Of course, this will not work with all plugins, but it offers another alternative if you have a plugin that was nice enough to be developed with a tmpl folder.

Upvotes: 2

Dean
Dean

Reputation: 8065

I have found a way to do this:

  1. Navigate to <joomla_homefolder>/administrator/language/<your_language>/
  2. Search for the plugin's corresponding language file.
  3. Copy the file name, EXCLUDING the language prefix (ie en-GB.) and the .ini suffix.
  4. In your template create a folder named html (a common practice for template overrides).
  5. In the html folder create a subfolder and name with the language file name as you copied it in step 3.
  6. Navigate to the tmpl subfolder in the plugin's path: <joomla_homefolder>/plugins/<plugin_type>/<plugin_name>/tmpl
  7. Copy the view file you wish to override into the folder you've created in step 5.
  8. Modify the copied file to override the plugins output.

For example - To change the page navigation buttons - modify the output of <joomla_homefolder>/plugins/content/pagenavigation:

Go into <joomla_homefolder>/administrator/language/en-GB/ and find the file named en-GB.plg_content_pagenavigation.ini.

From the filename copy only plg_content_pagenavigation.

Create a folder named html (If it does not exist already) in your theme, inside it create a subfolder and name it plg_content_pagenavigation.

Copy the view file <joomla_homefolder>/plugins/content/pagenavigation/tmpl/default.php into the plg_content_pagenavigation folder you just created.

Modify the file.

Note: I have tried it only with Joomla 3.1. The method may not work with some plugins.

Good Luck.

Upvotes: 9

Elin
Elin

Reputation: 6755

No you can't override the same way because there is not tmpl folder because plugins really should not be rendering though of course a lot do. You probably need to clone the plugin and make a the layout your want possibly using a jlayout to make it easier to manage.

Upvotes: 1

Related Questions