Friday, 28 February 2014

Rendering a module inside a component

The code to render module in component.

$document = &JFactory::getDocument();
$render = $document->loadRenderer('module');
$module = &JModuleHelper::getModule('Module Name');
$params = "p=vipul\n\rp1=patel";
$module->params = $params;
echo $render->render($module);

You can access both p and p1 parameters using.
$params->getValue("p") ;
$params->getValue("p1") ;


Friday, 7 February 2014

How to insert category in joomla 2.5?

$category =& JTable::getInstance('Category');
$category->title = [title];
$category->parent_id = [parent id];
$category->level = [level];
$category->extension = 'com_content';
$category->published = 1;
$category->params = json_encode(array('category_layout' => '', 'image' => ''));
$category->language = '*';
$category->metadata = json_encode(array('author' => '', 'robots' => ''));
$category->access = 1;
$category->setLocation([parent id], 'last-child');
if (!$category->check()) {
          echo  $category->getError();
}
if (!$category->store()) {
        echo $category->getError() . ' ( row:  ' . $i . ')';
}
if (!$category->rebuildPath($category->id)) {
         echo $category->getError();
}
if (!$category->rebuild($category->id, $category->lft, $category->level, $category->path)) {
          echo $category->getError()
}