2012-02-08 85 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