Manjeet Patel
Manjeet Patel

Reputation: 183

How to Call Joomla Component into module?

I am using Joomla site, I want to call some controller+model+View of one component into module. How this possible.

I looking for code to using that we create object of Jcontroller and then get output of view into module, also View used some model for same component

Thanks Manjeet

Upvotes: 1

Views: 5736

Answers (1)

jdog
jdog

Reputation: 2549

//set up any request variables that your component controller may need    
JRequest::setVar('var1','x');
JRequest::setVar('var2','y');

//include your controller and any other files
require_once(JPATH_BASE.'components'.DS.'your_component'.DS.'controllers'.DS.'yourcontroller.php');

//Do you need to tell your component you need module output?
$config = array();
$config['source'] = 'module';
$controller = new yourController($config);

$controller->execute('display');

//Reset any Request vars you have set
JRequest::setVar('var1','');
JRequest::setVar('var2','');

Upvotes: 6

Related Questions