简体   繁体   中英

render joomla module content on custom page

So I want to render a custom_html module which has just an image and some text on it, in a pop-up window. I am using custom_html as a "cheap" backoffice. I just want to extract the info from the module content.

So I know the module id (180), how can I render that particular module on a custom page that's independent of the rest? What type of includes I need to state at the beginning of the php file? I know I have to setup some constants and imports, but not sure what's the "right" way or "joomla way" of doing this, I thought that this would be a simple task, where is what I have so far:

include(JPATH_BASE.'libraries/loader.php');
jimport( 'joomla.application.module.helper' );

Thank you all

I would probably write a custom tmpl-file to handle this:

  • Create a file module.php in /templates/yourtemplate/
  • module.php can contain the following:
 <html><head><title>My module</title></head> <body> <jdoc:include type="modules" name="mymodule" style="xhtml"> </body> </html> 

possibly including other stuff that you need. Set up the module to display on all pages, using position mymodule.

Now you can call the modal window from anywhere using the following code:

<?php JHTML::_('behavior_modal'); ?>
<a href="<?php echo JRoute::_('index.php?Itemid='.$youritemid.'&tmpl=module'); ?>" 
class="modal" rel="{size: {x: 700, y: 500}, handler:'iframe'}">

This will display the module using the module.php file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM