Joomla 1.7:从系统插件中更改元标记

时间:2012-01-17 09:13:17

标签: plugins joomla

Joomla 1.7版 管理部分启用了插件

插件代码:

<?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');    
    }   
}

但这不起作用

元描述呈现值,在全局配置中设置

插件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>admin@joomla.org</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>

1 个答案:

答案 0 :(得分:2)

使用onBeforeRender代替onAfterRender

当触发onAfterRender事件时,应用程序的输出已在响应缓冲区中可用。