2013-06-24 102 views
1

我剛開始與Joomla一起工作,並且仍在嘗試通過製作自定義模塊的最佳實踐工作。我正在創建一個新聞跟蹤器,從我的helper.php文件中的一個函數生成一個外部XML項目列表。在彈出窗口中顯示Joomla模塊的內容

基於$ _GET ['id']變量,我想將我的mod_modulename.php轉發到不同的模板文件(default.php和popup.php)。你能猜到,我希望我的模塊來顯示新聞條目列表:

  • 新聞條目標題1
  • 新聞條目標題2
  • 新聞條目標題3

點擊它們應該打開一個只包含新聞內容(標題,圖片,內容)的彈出窗口,但由於Joomla的框架結構,並且不想在popup.php中放置任何PHP代碼或函數調用,所以我遇到了問題。

如果它是一個組件,我可以簡單地將可點擊的新聞標題鏈接到帶有?option = com_componentname的url。因爲它是一個模塊,所以這不起作用(或者我還沒有發現如何)。檢索popup.php中的內容似乎很混亂,並且沒有定義的('_ JEXEC')鏈接到mod_modname.php'控制器'就是不好的做法。

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 

如何解決這個沒有運行到不良行爲或開發一個附加組件添加到這個模塊有什麼建議? (不包括有關使用彈出窗口的爭論)

回答

0

試試這個,

$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); 

更多Here

相關問題