Component in Module [DEV]

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
mrWoozie
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Oct 19, 2017 2:12 pm

Component in Module [DEV]

Post by mrWoozie » Thu Oct 19, 2017 2:28 pm

Hi,

I've created some components, each one have some custom views to use in module.
Then I've created modules to display these components. In module configuration I can choose some parameters needed for components do display proper data and view.

The problem is - I can't make component to work in module.
Looks like component don't want to load files itself.

I've try lot of things. Here is one of idea:

Code: Select all

$option = $app->input->get('option',null);
$view = $app->input->get('view',null);
$layout = $app->input->get('layout',null);
$task = $app->input->get('task',null);
$id = $app->input->get('id',null);

$component = 'com_component';
$view = 'component';
$id = 1;

$app->input->set('option',$component);
$app->input->set('view',$view);
$app->input->set('layout',null);
$app->input->set('task','display');
$app->input->set('id',$id);

JModelLegacy::addIncludePath(JPATH_SITE .DS. 'components' .DS. $component);
JLoader::discover('Contact', JPATH_SITE .DS. 'components' .DS. $component .DS, false, true);

require_once (JPATH_SITE .DS. 'components' .DS. $component .DS. 'controller.php');

$controller = new someController();

$controller->setProperties(array(
	'basePath' => JPATH_SITE .DS. 'components' .DS. $component,
	'paths' => array(
		'view' => array(
			JPATH_SITE .DS. 'components' .DS. $component .DS. 'views'
		)
	)
));

$controller->execute('display');
Is there any function to "run" component?
Last edited by imanickam on Fri Oct 20, 2017 2:23 am, edited 2 times in total.
Reason: Moved the topic from the forum Extensions for Joomla! 3.x to the forum Joomla! 3.x - Coding

User avatar
imanickam
Joomla! Master
Joomla! Master
Posts: 26778
Joined: Wed Aug 13, 2008 2:57 am
Location: Chennai, India

Re: Component in Module [DEV]

Post by imanickam » Thu Oct 19, 2017 2:58 pm

Probably review of the extensions such as Components Anywhere (https://extensions.joomla.org/extension ... -anywhere/) would help in understanding how things are implemented.
Ilagnayeru (MIG) Manickam | இளஞாயிறு மாணிக்கம்
Global Moderators Team | Translations Coordination Team | Tamil (தமிழ்) Translation Team

Eegan - Support the poor and underprivileged

mrWoozie
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Oct 19, 2017 2:12 pm

Re: Component in Module [DEV]

Post by mrWoozie » Thu Oct 19, 2017 4:41 pm

imanickam wrote:Probably review of the extensions such as Components Anywhere (https://extensions.joomla.org/extension ... -anywhere/) would help in understanding how things are implemented.
Thank's I was checking it. I'm wondering if there is any simpler way using Joomla methods.


Post Reply

Return to “Joomla! 3.x Coding”