【问题标题】:Get component content in joomla在joomla中获取组件内容
【发布时间】:2012-02-27 01:12:53
【问题描述】:

我正在制作一个系统插件,我需要一种将 html 放在任何组件之前和标题、菜单 ecc 之后的方法。换句话说,我需要将 html 放在模板中:

<jdoc:include type="component" />

谢谢

【问题讨论】:

    标签: plugins joomla components


    【解决方案1】:

    我找到了我需要的东西:

      // get the document object.
      $doc = JFactory::getDocument();
    
      // get the buffer
      $buffer = $doc->getBuffer('component');
    
      // your string to insert
      $insert_string = "<p>I've been inserted</p>";
    
      // insert the string
      $buffer = $insert_string . $buffer;
    
      // reset the buffer
      $doc->setBuffer($buffer, 'component');
    

    【讨论】:

      【解决方案2】:

      如果你想修改网页的内容,那么你应该制作一个“内容”插件而不是一个“系统”插件。

      一个好的起点是查看 Joomla 附带的 emailcloak 插件! 1.6+(请注意,Joomla! 1.5 的插件界面与当前 1.6/7/2.5 时代的插件完全不同)。如果您使用的是 1.5,请查看随附的 example 插件。

      本文档涵盖“Creating a content plugin

      【讨论】:

      • 我的理解是内容插​​件只有com_content的范围,组件需要系统插件(v3.1)不是这样吗?
      • 否,例如 emailcloak 在模块、网络链接等中工作——插件正在响应事件。内容插件获得onContentPrepare,第一个参数是context,它是组件的标识符,例如您注意到核心插件检查上下文不是 com_finder.indexer 话虽如此,组件必须正确编写才能触发相关事件,以便您的插件使用它们。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-21
      • 1970-01-01
      • 1970-01-01
      • 2013-01-19
      • 1970-01-01
      相关资源
      最近更新 更多