BzZzZ - ustvarjamo podobe logo
slovenščina
english
How to display Joomla component in a module

inspired by the Ignite gallery, here is some more Joomla wizardry

A quick way to display your component in a module - place the following code in the main module file:

defined('_JEXEC') or die('Restricted access');

$view = JRequest::getCmd('view',null);
$layout = JRequest::getCmd('layout',null);
$task = JRequest::getCmd('task',null);

JRequest::setVar('view', 'someview');
JRequest::setVar('layout', 'default');
JRequest::setVar('task', 'sometask');

$lang = JFactory::getLanguage();
$lang->load('com_something', JPATH_ADMINISTRATOR);

if (!class_exists('SomethingController')) {
require_once (JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_something' .DS. 'controller.php');
}

$controller = new SomethingController();
$controller->execute('sometask');

// revert system vars to previous state

if($view != null)
{
JRequest::setVar('view', $view);
}

if($layout != null)
{
JRequest::setVar('layout', $layout);
}

if($task != null)
{
JRequest::setVar('task', $task);
}

 

If your component uses more variables e.g. category, id etc. you need to set them too before you call controller->execute(). Don't forget to revert those to values from current component if variables are commonly used ones like id.

You will also need module .xml file, but that should be pretty easy with only one file :)

 

DISCLAIMER: No Ninjas were harmed while performing this magic

 
  • strateško usmerjeno
  • integrirano
  • s kreativnostjo pospešeno
  • učinkovito komuniciranje
© BzZzZ 2008
stik z nami    zaposlitev    kazalo strani