2

I am looking for a way to override the joomla.edit.params layout only for the com_content, which is rendered with the: JLayoutHelper::render('joomla.edit.params', $this)
on the:
administrator/components/com_content/view/article/tmpl/edit.php, at about line 135.

How can I use a different layout only for the com_content component?

1 Answer 1

3

It is possible to create an override for the edit params layout only for the com_content component.

In general the JLayout system will search for overrides in the following folders, with priority order as shown:

1. templates/mytemplate/html/layouts/com_mycomponent
2. components/com_mycomponent/layouts
3. templates/mytemplate/html/layouts
4. layouts

There is a thorough presentation of the new JLayout here.

Below I will describe how I did this override, since I also needed to override the edit.php template for the com_content.

First you will need to create a new folder for the custom layout overrides. I would choose to create a folder named "overrides" and put it in:

administrator/templates/isis/html/layouts/overrides

The JLayoutHelper:render method will first search inside this folder when looking for the joomla.edit.params layout. In order to load it, you will need to keep the same structure inside the overrides folder. So the params.php file should be placed like: /overrides/joomla/edit/params.php

Then, you will need to create an override for the edit.php template file of the article view, from which you will call the custom layout.

Inside the html folder of the isis temlpate, create a folder for the com_content overrides, name it "com_content", and then a folder for the article view's template files, named "article". Copy the edit.php file from the component and drop it in the article folder.

Now, inside the edit.php, you can adjust the JLayoutHelper::render method and pass to it a new base path to look for the alternative layout like below:

<?php echo JLayoutHelper::render('joomla.edit.params', $this, $basePath = JPATH_ADMINISTRATOR .'/templates/isis/html/layouts/overrides'); ?>

This will look for a params.php layout, inside the : administrator/templates/isis/html/layouts/overrides/joomla/edit folder.

You can keep things simpler if you just place the params.php inside the overrides folder and call it like:

<?php echo JLayoutHelper::render('params', $this, $basePath = JPATH_ADMINISTRATOR .'/templates/isis/html/layouts/overrides'); ?>

Finally, remember to also add index.html files inside any newly created folder.

JLayout Useful Links:

  1. JLayout Presentation at Joomla Magazine
  2. Sharing Layouts across views or extensions - Tutorial
  3. Joomla: Layout API
1
  • Is it possible to add another path for layout overrides except the four mentioned above? I need to put custom layout files in a library where multiple extensions can use them.
    – Mike
    Commented Nov 2, 2020 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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