1
votes

I've just started to work with Joomla and am still trying to work myself through best practises of making custom modules. I'm working on a news tracker creating a list of items from an external XML, generated by a function in my helper.php file.

Based on a $_GET['id'] variable, I want to forward my mod_modulename.php to a different template file (default.php and popup.php). You can guess, I want my module to show the news item list:

  • News item title 1
  • News item title 2
  • News item title 3

Clicking on them should open a popup with only the content of the news item (Title, Image, Content), but due to the framework structure of Joomla and not wanting to put any PHP-code or function calls in the popup.php I'm running into issues.

If it were a component, I could simply make the clickable news titles link to an url with ?option=com_componentname. Because it is a module, this doesn't work (or I haven't discovered how to). Retrieving the content inside popup.php seems messy, and linking to a mod_modname.php 'controller' without a defined('_JEXEC') is just bad practise IMHO.

helper.php // retrieves content for mod_modname.php
mod_modname.php // gets the data from helper.php and loads views depending on $_GET['id']
default.php // default view listing the news items in different layouts (list-style, blog-style, etc.)
popup.php // should display only the newsitem selected, not the entire Joomla template

Any suggestions on how to solve this without running into bad practises or developing an additional component to this module? (Excluding the debate about using popups)

1

1 Answers

0
votes

Try This,

 $document = &JFactory::getDocument();
 $renderer = $document->loadRenderer('module');

 $Module = &JModuleHelper::getModule('mod_fmDataGrid');

 $Params = "param1=bruno\n\rparam2=chris";//This will only required when you pass module params through code
 $Module->params = $Params;
 echo $renderer->render($Module);

For more Here