Get component output

For Joomla! 2.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Note: All 1.6, 1.7 and 3.5 releases have reached end of life and should be updated to 3.x.

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
dgrey
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Dec 10, 2012 10:34 am

Get component output

Post by dgrey » Mon Dec 10, 2012 10:56 am

Hello, I'm programming a component in joomla 2.5

This component needs to retrive the display (the view) of another component (for example it need to get the formatted content of an article, as an html string.
In other terms, i need to get the return of the display method of the component from another component, is that possible?

Thanks.

User avatar
Ratmil
Joomla! Explorer
Joomla! Explorer
Posts: 318
Joined: Sat Dec 06, 2008 7:07 pm

Re: Get component output

Post by Ratmil » Mon Dec 10, 2012 1:43 pm

I would try something like this:

Code: Select all

$ch = curl_init();
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_URL, "localhost/joomla/index.php?option=com_yourcomponent&tmpl=component");
ob_start();
curl_exec($ch);
$ret_str = ob_get_contents();
curl_close($ch);
ob_end_clean();

dgrey
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Dec 10, 2012 10:34 am

Re: Get component output

Post by dgrey » Mon Dec 10, 2012 11:18 pm

Well this could work, but it's not very efficient. With curl i will need to make http request calls for every page...it can be slow and waste bandwith maybe.

Also i want only the component output, with this I would get the graphical template, all the modules and the component inside.

User avatar
Ratmil
Joomla! Explorer
Joomla! Explorer
Posts: 318
Joined: Sat Dec 06, 2008 7:07 pm

Re: Get component output

Post by Ratmil » Tue Dec 11, 2012 5:39 am

Check that I have used "tmpl=component"
This removes all except component output.

You could use JComponentHelper::renderComponent($component);
But wouldn't work.


Locked

Return to “Joomla! 2.5 Coding”