Need help with plugin layer

Discussion in 'PHP' started by xxKillswitch, Oct 23, 2009.

  1. #1
    I am working on a cms, and have integrated a plugin layer based on Joomla 1.0. I have it working with my CMS... sorta.

    Basically, I have set up two dummy plugins. One replaces {google} with an adsense block, and the other replaces {url} with the site url ( just dummy plugins ).

    Now, it runs, but prints the content its replacing the tags in twice, once for each plugin. I have been messing with this script for awhile and just can't figure out how to get it to stop this duplication.

    I have attached the plugin handler code, and a sample useage code. I did not provide the plugins, instead will paste a plugin sample below...

    
    $opc->plugins->registerFunction('onAlterContent', 'googleReplacer');
    
    /**
    * Searches and replaces {google} in text
    * @return Altered text
    */
    function googleReplacer($content) 
    {
    	// Check to see if there is anything to replace first.  If nothing, simply return the text.
        if(strpos($content, '{google}' ) === false) 
    	{
    		return $content;
    	} 
    	else 
    	{
    		// The tag was found, now we must replace it with our google code
            $code = 'THIS WILL BE THE GOOGLE ADSENSE BLOCK';
            $content = str_replace('{google}', $code, $content);	
            return $content;
        }
    }
    
    Code (markup):
    Just something basic to test the waters with. I am tired of manually adding these files and adding in the function, and really dont have too much time to sit down and write my own plugin handler ( if I even could ). Thanks for any help.
     

    Attached Files:

    xxKillswitch, Oct 23, 2009 IP
  2. xxKillswitch

    xxKillswitch Peon

    Messages:
    331
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sorry, Solved. I was returning the content in the plugin themselves rather than just returning true or simply, returning.
     
    xxKillswitch, Oct 23, 2009 IP