2012-01-12 86 views
0

我周圍搜索了很多,但我沒有找到任何好的信息 添加自定義字段到Joomla文章(com_content & view = edit)。只是你如何破解Joomla的核心文件來添加自己的領域,但它不是我的替代方案。Joomla文章編輯,customfield

我認爲最好的方法就是創建一個自己的插件,但我會卡在這裏。我已經創建了一個插件到組「系統」,但我的插件不會被觸發。

有誰知道我該如何解決這個好方法?

我的插件customfield.php:

<?php 
// no direct access 
defined('_JEXEC') or die('Restricted access'); 
jimport('joomla.plugin.plugin'); 

class plgSystemCustomField extends JPlugin { 

    function onContentPrepareForm($form, $data) 
    { 
     echo "Trigger 1???"; 
     if($form->getName() == 'com_content.article') { 
      JForm::addFormPath(dirname(__FILE__).'/form'); 
      $form->loadFile('customfield', false); 
      print_r($form); 
     } 
     return true; 
    } 

    function onDisplay() { 
     echo "Trigger 2???"; 
    }   
} 
+0

我解決了這個問題。 – Rond 2012-01-12 20:05:05

回答

1

一個Joomla的主要弱點之一是添加自定義字段的難度。在各種Joomla論壇中有很多關於此的討論。雖然這並不容易,但目前的解決方案是使用「CCK」之一或高級形式的擴展名,例如:http://extensions.joomla.org/extensions/authoring-a-content/content-construction

+0

我發現了一篇關於它的博文,http://developer-blog.com/create-custom-fields-to-joomla/工作正常:)。 – Rond 2012-03-21 12:29:16

+0

Rond,目前唯一能夠以任何有意義的方式在Joomla中真正實現自定義字段的方法是添加CCK。這開啓了自己的挑戰。但是如果你想讓你的Joomla網站更加個性化,那麼沒有其他選擇。 – MatthewSchenker 2012-03-21 18:40:59