0

I am writing PHP API for Joomla3.9 website where I need to deliver the HTML produced by mod_articles_category modules. I tried blow code to get Module HTML output but it does not working any more It shoiwng the erro someting like that "Call to a member function get() on null"

define('_JEXEC', 1); 
include_once DIR . '/defines.php';
require_once JPATH_BASE . '/includes/defines.php'; 
require_once JPATH_BASE . '/includes/framework.php'; 
$app      = JFactory::getApplication('site');

jimport('joomla.application.module.helper'); 

$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module'); 
$module   = JModuleHelper::getModule('mod_articles_category', 'Module title I used here'); 

echo $renderer->render($module); 

?> 

Basically I need this module HTML output in the same way as it render on Joomla pages so that I can send this out to REST API user. It showi

Please suggest me

  • Please describe exactly how it doesn't work anymore. This is essential in a complete question. Are you seeing errors? Blank screen? Mangled output? Some volunteers will already know, but it makes your question higher value to express what isn't working properly. – mickmackusa Dec 28 '18 at 4:51
  • This is my complete php code define('_JEXEC', 1); include_once DIR . '/defines.php'; require_once JPATH_BASE . '/includes/defines.php'; require_once JPATH_BASE . '/includes/framework.php'; $app = JFactory::getApplication('site'); jimport('joomla.application.module.helper'); $dispatcher = JEventDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $document = JFactory::getDocument(); $renderer = $document->loadRenderer('module'); $module = JModuleHelper::getModule('mod_articles_category', 'Module title I used here'); echo $renderer->render($module); ?> – Mukesh Nandeda Dhakad Dec 28 '18 at 5:01
  • It showing not a blank page only – Mukesh Nandeda Dhakad Dec 28 '18 at 5:04
  • Please edit your question, then delete your comments. – mickmackusa Dec 28 '18 at 5:07
0

Use JModuleHelper::renderModule($module) instead of $renderer->render($module) also add code in your question along with the value of $module object, so we can understand your issue better and provide solutions accordingly.

  • I tried your code it showing error Call to a member function getTag() on null – Mukesh Nandeda Dhakad Dec 28 '18 at 18:03
  • Your API called for this code is directed from controller or accessing a file directly? As you are loading the framework. If you are redirected from the controller framework will be included already, in your case you will not be receiving any value in the $module, it may be due to the framework or any dependent file not included properly. – Pratyush Jan 2 at 6:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.