2010-10-06 48 views
0

我想做一個設置來在後端插入文章ID。Joomla自己的組件設置插入文章彈出

情景是:用戶可以點擊一個按鈕,窗口將出現文章列表,比可以選擇文章。文章ID將存儲在組件配置中。

比我能填充在FrontPage中的文章(這部分我知道)

+1

來吧Joomla!是開源的。你所描述的是在菜單系統中實現的。您是否看過該代碼並嘗試將其移植到您的組件? – silvo 2010-10-06 09:15:31

回答

1

你需要做到以下幾點:

  1. 添加路徑到Joomla文章內容元素
  2. 該元素
  3. 的創建實例
  4. 顯示它

`

<?php 
// I created the element inside of the view, $this is my View. 
// It can be model/view/controller. Does not matter 

// Include Element 
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'elements' . DS . 'article.php'; 

// Create Instance 
$articleElement = new JElementArticle($this); 

// Output article 
echo $articleElement->fetchElement('article', 0, $this, 'myparam'); 

// NOTE: name of article_id element will be myparam[article] 
?> 

如果你想改變元素的外觀,你需要重載/修改元素。這很容易做到,你可以複製site/administrator/components/com_content/elements/article.php,進行更改,你會得到你自己的元素版本。不要修改article.php組件,你會搞砸Joomla的東西,如果你計劃在未來更新你的網站......你會在更新後失去改變。

+0

哇我很感動Joomla如何簡單的事情:)非常感謝! – miojamo 2010-10-07 08:28:52

+0

他們很簡單...但你需要知道的東西。理解框架非常重要,如果你想深入瞭解框架書籤這個頁面http://docs.joomla.org/Framework。知識就是力量! – Alex 2010-10-08 00:13:02