rendering another component within a component

1,202 views
Skip to first unread message

gobezu

unread,
Oct 23, 2010, 7:29:45 AM10/23/10
to Joomla! General Development
Hi all,

I have been looking at
joomla.application.component.helper::renderComponent and its obvious
that - at least due to the various JPATH_COMPONENT* constants - its
not possible to render a component within a component

Is there any way anyone can advise me to do this?
Maybe some custom renderComponent someone have already in place and
wouldn't mind to share?

I do realize that I could make http request with tmpl=component and
collect the rendered results but that's really not what I would like
to do for the following reasons:
1. feels conceptually so wrong to hit the server again while I am
right in the server executing
2. I would like to merge the rendering parameter with one that is
dynamically built

I have been searching in all Jooma! related groups and I just haven't
found any related discussions which makes me wonder if this need is
really that unique or maybe too off...

Thanks

Herman Peeren

unread,
Oct 24, 2010, 6:39:27 AM10/24/10
to Joomla! General Development
The way to do what you want in Joomla! is not using renderComponent,
but calling parts of another component directly. See for instance
here: http://www.corephp.com/blog/joomla-mvc-load-a-model-from-anywhere/#more-2058

Best would be to call the controller of another MVC-triad from the
controller of your "parent"-component. In that way you'll get a
hierarchic "tree" of MVC-triads. That is called HMVC. In Joomla! there
are no native provisions to use that, but you can always program it
yourself; just beware that you don't redirect from your sub-
controller. In Nooku-Framework, which you can easily use within
Joomla!, there are native provisions. See:
http://www.torkiljohnsen.com/2010/09/14/advancing-from-joomla-mvc-to-nooku-hmvc/

Another nice explanation of HMVC (using the Kohana Framework) is on
http://techportal.ibuildings.com/2010/02/22/scaling-web-applications-with-hmvc/

Drupal uses this HMVC-principle too; there it is called PAC. See
http://en.wikipedia.org/wiki/Presentation-abstraction-control

Duccio M. Gasparri

unread,
Apr 16, 2012, 8:28:54 AM4/16/12
to joomla-de...@googlegroups.com
I spent two days trying to find a solution to integrate three components in the same page, but in the end I gave up and solved it by myself.

http://www.ducciogasparri.com/2012/04/15/joomla-loading-multiple-components-in-a-single-page/

There's also a file with the modified renderComponent function. Hope it helps somebody

Duccio
Reply all
Reply to author
Forward
0 new messages