简体   繁体   中英

Change PHP code Joomla plugin

How to change the code so that text "I am a happy plugin" appears only in the archived items?.

This is the PHP code:

<?php
// No direct access allowed to this file
defined( '_JEXEC' ) or die( 'Restricted access' );

// Import Joomla! Plugin library file
jimport('joomla.plugin.plugin');

//The Content plugin MakePlugIn
class plgContentMakePlugIn extends JPlugin
{
    function plgContentMakePlugIn (&$subject)
    {
        parent::__construct ($subject);
    }
    function onPrepareContent (&$article, &$params, $page=0)
    {
        print "I am a happy plugin";
    }
}
?>

Looks like this is what you are looking for:

function onPrepareContent (&$article, &$params, $page=0)
{
    if ($article->state==-1) {
        print "I am a happy plugin";
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM