1

I install together with my component a few modules. Also one for the backend. This shall be directly activated via the script. So I have a few lines added to update the #__modules table to get this result. But it seems not to be possible. Only when I save this module manually in the backend it is viewed.

Here is what I have tried:

$installer = new JInstaller;
$result = $installer->install($src_modules.DS.'mod_test_admin_stats');
$status->modules[] = array('name'=>'mod_test_admin_stats','client'=>'admin', 'result'=>$result);

// admin stats module should now be published on position 'jdcpanel'.
$mod_array = array ("view_latest" => "1", "view_popular" => "1", "view_featured" => "1", "view_most_rated" => "1", "view_top_rated" => "1", "amount_items" => "5", "view_statistics" => "1", "view_monitoring_log" => "1", "view_restore_log" => "1", "view_server_info" => "1", "layout" => "_:default", "moduleclass_sfx" => "", "cache" => "1", "cache_time" => "900", "module_tag" => "div", "bootstrap_size" => "0", "header_tag" => "h3", "header_class" => "", "style" => "0");
$mod_params = json_encode($mod_array);
$date = JFactory::getDate();
$nowDate = $db->quote($date->format($db->getDateFormat()));
$db->setQuery("UPDATE #__modules SET `published` = '1', `publish_up` = ".$db->quote($nowDate).", `position` = 'jdcpanel', `ordering` = '1', `params` = '".$mod_params."' WHERE `module` = 'mod_test_admin_stats'");
$db->execute();

Is something else required to get that what I need?

  • Okay, I have get it: 1) The 'published' field must be 1 in the #__modules table 2) The 'enabled' field must be 1 in the #__extensions table 3) In the table #__modules_menu must also exist a data set with the module ID in the field 'moduleid' and a value in the field 'menuid' (can also be 0) – mikael Sep 6 '18 at 13:13
  • When you are able to self-solve, please take the time to craft a complete, formatted, educational answer, then award your answer with the green tick so that this page is deemed resolved. (Then please delete your comment.) – mickmackusa Oct 19 '18 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.