简体   繁体   中英

Load a joomla module in an external php page

I'm using Joomla 3.

I would like to add one of my joomla modules to a separate(from joomla) PHP page. is this possible?

From what I could find online, I need to call the joomla framework and then ??????? and then it works.

<?php define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise(); 


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>


</head>

<body>


                    <jdoc:include type="modules" name="position-22" style="none" />



</body>
</html>

Yes, It's Possible

  • Initialize Joomla Framework (From Joomla 3.4.1 index.php)

     define('_JEXEC', 1); if (file_exists(__DIR__ . '/defines.php')) { include_once __DIR__ . '/defines.php'; } if (!defined('_JDEFINES')) { define('JPATH_BASE', __DIR__); require_once JPATH_BASE . '/includes/defines.php'; } require_once JPATH_BASE . '/includes/framework.php'; $app = JFactory::getApplication('site'); $app->initialise(); 
  • After initializing you can call your module position using JHtml

     echo JHtml::_('content.prepare', '{loadposition position-22}'); 

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