JLayoutHelper::render and template overrides

4,227 views
Skip to first unread message

Davide Tampellini

unread,
May 10, 2013, 2:29:04 AM5/10/13
to joomla-de...@googlegroups.com
Hi, I'm working on Joomla 3.1.1 and I'm trying to create a template override for com_content.
Looking at the code, it seems that the method JLayoutHelper::render doesn't "trigger" the template overrides logic.

Is that correct or am I missing something?
How can I deal with that?

Davide Tampellini

unread,
May 10, 2013, 2:19:13 PM5/10/13
to joomla-de...@googlegroups.com
Thanks a lot!

On Friday, May 10, 2013 10:03:54 AM UTC+2, Seth Warburton wrote:

Hi Davide,

I ran into the same issue myself a little while ago!

You can now override individual layouts from within your template. Default layouts are in the /layouts/ folder and you can override them in your template the same way you did previously. For example, to modify the blog item title layout copy:

layouts/joomla/content/blog_style_default_item_title.php

to:

templates/*your template*/html/layouts/joomla/content/blog_style_default_item_title.php

For further info you should check out: http://docs.joomla.org/Sharing_layouts_across_views_or_extensions_with_JLayout

Regards,


Seth

Seth Warburton

unread,
May 10, 2013, 2:46:05 PM5/10/13
to joomla-de...@googlegroups.com
My pleasure. 

shumisha

unread,
May 11, 2013, 4:08:54 AM5/11/13
to joomla-de...@googlegroups.com
Hi Davide,

Not sure what code you looked at to reach this conclusion.

JLayoutHelper::render() is just a shortcut to do:
$layout = new JLayoutFile('some.layout');
$renderedHtml = $layout->render($data);

Templates overrides are applied the same when using the helper or when creating yourself the JLayout Object.

The helper is handy if you don't re-use the JLayout object in your view, while it's (very slightly) more efficient to manage your own JLayout object if you reuse it several times, simply passing different data to the render method.

For instance, you could use the helper to display the tab set start and end (there's only one start of tabs set and one end), but you wold have your own JLayout object for each tab start, and reuse it in your layout, for each new tab.
(note this is an example, you should use JHtml::_('bootstrap.startTabSet',...) et al. to display tabs).

So in short:

- JLayout were overridables in template from day one, in J! 3.0
- Using JLayoutHelper, introduced in 3.1 I think doesn't change that

Rgds
Reply all
Reply to author
Forward
0 new messages