2012-01-17 41 views
0

的Joomla 1.7版本 插件啓用在管理部分的Joomla 1.7:從系統插件改變meta標籤

插件代碼:

<?php 
// no direct access 
defined('_JEXEC') or die; 

jimport('joomla.plugin.plugin'); 

class plgSystemMetatags extends JPlugin 
{ 
    public function __construct(&$subject, $config) 
    { 
     parent::__construct($subject, $config); 
    } 

    public function onBeforeRender() 
    { 
     $document =& JFactory::getDocument(); 
     $document->setMetaData('keywords', 'test keywords');  
    } 
} 

但這不起作用

Meta描述呈現價值,其中設置爲全局配置

插件xml文件

<?xml version="1.0" encoding="utf-8"?> 
<extension version="1.7" type="plugin" group="system" method="upgrade" client="site"> 
    <name>System - Metatags</name> 
    <author>Joomla! Project</author> 
    <creationDate>November 2005</creationDate> 
    <copyright>Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.</copyright> 
    <license>GNU General Public License version 2 or later; see LICENSE.txt</license> 
    <authorEmail>[email protected]</authorEmail> 
    <authorUrl>www.joomla.org</authorUrl> 
    <version>1.7.0</version> 
    <description></description> 

    <files> 
     <filename plugin="metatags">metatags.php</filename> 
     <filename>index.html</filename> 
    </files> 

</extension> 

回答

2

使用onBeforeRender而不是onAfterRender

onAfterRender事件被觸發時,應用程序的輸出已經在響應緩衝區中可用。

+0

謝謝,但我想通了,Joomla甚至不執行我的插件。它在系統中啓用。 – sbxmal 2012-01-17 09:48:51

+0

但是,您仍然需要使用onBeforeRender – Gaurav 2012-01-17 09:53:55

+0

我將事件更改爲onBeforeRender - 即使當我將錯誤的構造放入該文件時也沒有任何錯誤。它根本不執行。 – sbxmal 2012-01-17 09:54:46