2012-02-08 121 views
0

我寫了一個Joomla插件!我說「書面」是因爲它實際上是其他人的,但它是用於Joomla 1.5,我試圖升級它以運行在Joomla 1.7中。但是,它已安裝並且不想運行。我試圖讓它從無到有產生錯誤,但它不會給我任何東西。 我甚至不確定它是否是Joomla 1.7代碼,但我希望你也可以幫忙。Joomla插件沒有運行(安裝)

<?php 

// no direct access 
defined('_VALID_MOS') or die('Restricted access'); 

jimport('joomla.plugin.plugin'); 

class plgContentRegisteredTags extends JPlugin 
{ 
    function plgContentRegisteredTags (&$subject, $params) 
    { 
     parent::__construct($subject,$params); 
    } 

    function onPrepareContent ($context, &$article, &$params, $page=0) 
    { 
     global $mainframe; 
     //if (!$published) return true; 

     // define the regular expression for the bot 
     $regex1 = "#{reg}(.*?){/reg}#s"; 
     $regex2 = "#{noreg}(.*?){/noreg}#s"; 

     // perform the replacement 
     $article->text = preg_replace_callback(
      $regex1, 
      create_function(
       '$matches', 
       'global $my; 
       if($my->id) return $matches[1]; 
       return "";' 
      ), 
      $article->text 
     ); 

     $article->text = preg_replace_callback(
      $regex2, 
      create_function(
       '$matches', 
       'global $my; 
       if(!$my->id) return $matches[1]; 
       return "";' 
      ), 
      $article->text 
     ); 

     return true; 
    } 
} 

注:它只是不希望在所有運行(沒有錯誤,不執行代碼),即使它被啓用和安裝。

任何幫助,將不勝感激。

+1

什麼是文件名和位於何處(相對於的Joomla根)安裝後? – Nobody 2012-02-08 16:24:34

+0

相對來說,它是'components/com_registeredtags/helloworld.php' – 2012-02-08 16:25:56

+1

我一段時間都沒有和joomla一起工作,但我記得組件文件的名稱有一些命名約定。我認爲它應該是'componentname.php'。所以它將是'registeredtags.php'而不是'helloworld.php'。 – Nobody 2012-02-08 16:32:01

回答

1

Joomla中的插件!存儲在相對於站點根的plugins/plugin-type/plugin_name/中。組件存儲在components/目錄中。

例如。在分頁符內容插件是在「插件/內容/分頁符/」發現其中包含的文件:

plugins/content/pagebreak/pagebreak.php 
plugins/content/pagebreak/pagebreak.xml 
plugins/content/pagebreak/index.html   // not an active file 

你可以閱讀有關creating a content plugin here.

+0

我會試試這個!謝謝! – 2012-02-10 10:00:08

+0

非常感謝了! – 2012-02-10 11:03:31