簡體   English   中英

在外部php頁面中加載joomla模塊

[英]Load a joomla module in an external php page

我正在使用Joomla 3。

我想將我的joomla模塊之一添加到單獨的(與joomla無關的)PHP頁面中。 這可能嗎?

從網上可以找到的地方,我需要調用joomla框架,然后調用??????? 然后它起作用。

<?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>

是的,有可能

  • 初始化Joomla框架(來自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(); 
  • 初始化后,您可以使用JHtml調用模塊位置

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM