2012-11-09 94 views
3

我想在我的模塊中呈現Joomla內容插件,該怎麼做?Joomla 2.5在我的模塊中呈現內容插件

這裏是我的代碼

<pre> 

<?php 
defined('_JEXEC') or die; 

$db = JFactory::getDBO(); 
$query = $db->getQuery(true); 
$query->select('stendas_id, stendas_lat, stendas_lon, stendas_name, stendas_description, stendas_kaire, stendas_desine') 
     ->from('#__stendukai_stendai') 
     ->where('published = 1'); 
$db->setQuery($query); 

$rows = $db->loadObjectList(); 

require JModuleHelper::getLayoutPath('mod_stendulist', $params->get('layout', 'default')); 

</pre> 

這裏是如default.php文件代碼

<pre> 
<?php 
defined('_JEXEC') or die; 

$document = JFactory::getDocument(); 

$document->addStyleSheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css');  
$document->addScript("http://maps.google.com/maps/api/js?sensor=false&language=en"); 
$document->addScript(JURI::base() . 'modules/mod_stendulist/libs/jquery.min.js'); 
$document->addScript(JURI::base() . 'modules/mod_stendulist/libs/jquery-noconflict.js'); 
$document->addScript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js'); 
$document->addScript(JURI::base() . 'modules/mod_stendulist/libs/jquery.ui.map.js'); 
$document->addScript(JURI::base() . 'modules/mod_stendulist/libs/frontend_map.js'); 
$document->addScript(JURI::base() . 'modules/mod_stendulist/libs/jquery.ui.map.services.js'); 
$document->addScript(JURI::base() . 'modules/mod_stendulist/libs/jquery.ui.map.extensions.js'); 

?> 

<div id="themapstuff"> 
    <table class="stendu_table" border="0" cellpadding="0" cellspacing="0" height="151" width="406"> 
     <tbody> 
     <tr><th width="33">Nr.</th><th width="115">Stendai</th><th width="74">Kairė</th><th width="74">Dešinė</th></tr> 
    <?php $i=1; ?> 


     <?php foreach ($rows as $row): ?> 
     <tr data-gmapping='{"id":" <?php echo $row->stendas_id ?>","latlng":{"lat": <?php echo $row->stendas_lat ?>,"lng": <?php echo $row->stendas_lon ?>},"tags":" <?php echo $row->stendas_name ?>"}'> 
      <td><?php echo $i++ ?></td> 
      <td> <span class="title"><?php echo $row->stendas_name ?></span> 
       <div class="info-box"> 
        <?php echo $row->stendas_description;?> 
       </div> 
      </td> 
      <td><?php echo $row->stendas_kaire ?></td> 
      <td><?php echo $row->stendas_desine ?></td> 

     </tr> 
     <?php endforeach ?> 
     </tbody> 
    </table>  
</div> 
</pre> 

如果有可能,我主要是有趣的運行內容插件

$row->stendas_description

beca使用這是實際的內容別人是身份證和別名。

回答

2

如果將Prepare Content參數設置爲true,則自定義html模塊將呈現插件。

JPluginHelper::importPlugin('content'); 

$module->content = JHtml::_('content.prepare', $module->content, '', 'mod_custom.content'); 

https://github.com/joomla/joomla-cms/blob/master/modules/mod_custom/mod_custom.php#L14

+0

此代碼是否需要位於插件本身中,還是位於要顯示嵌入式插件的模塊中? – Edward

+1

該代碼位於模塊中。它正在調用內容插件。 – Elin