Page 1 of 1

[solved] {content|smileys} "Smarty error [plugin] modifier 'smileys' is not

Posted: Thu Aug 16, 2007 6:29 pm
by tobik
Hi all

I use cmsms core 1.1 and the Smileys module 0.1.3.

When I insert {content|smileys} into a template everything works fine on the first page load. But on any further load the page shows an php error:

Code: Select all

string(121) "Smarty error: [in template:17 line 120]: 
[plugin] modifier 'smileys' is not implemented (core.load_plugins.php, line 124)"
Does anybody know howto work around that?

Thanks, Tobik

Re: {content|smileys} "Smarty error [plugin] modifier 'smileys' is not implement

Posted: Fri Aug 17, 2007 5:39 am
by cyberman
tobik wrote: When I insert {content|smileys} into a template
Smileys is not a Smarty modifier

http://smarty.php.net/manual/en/language.modifiers.php

Smileys is a module you can use it with guestbook module for instance

Re: {content|smileys} "Smarty error [plugin] modifier 'smileys' is not implemented"

Posted: Fri Aug 17, 2007 6:49 am
by tobik
Hi all, thanks for your responses.

@mark
I used textsmileys over the years on my static homepage and it would be a nice giveaway if they turn to grafic smileys in cmsms.

@cyberman
The smileys help does list this syntax {content|smileys}
And sure on the first page load the grafic smileys does appear in my text. But unluckily any reload of the page throws the error mentioned above.

Re: {content|smileys} "Smarty error [plugin] modifier 'smileys' is not implemented"

Posted: Sat Aug 18, 2007 8:58 pm
by tobik
@cyberman
Just found this code in Smileys.module.php

Code: Select all

	function SmartyPreCompile(&$content) {
		$this->smarty->register_modifier("smileys",array(&$this,"SmartyModifier"));
	}
I assume the use of smileys as modifier is correct and intended. Isn't it?

Re: {content|smileys} "Smarty error [plugin] modifier 'smileys' is not implemented"

Posted: Mon Aug 20, 2007 11:41 am
by cyberman
Right - never used this option ...

Re: {content|smileys} "Smarty error [plugin] modifier 'smileys' is not implemented"

Posted: Tue Aug 21, 2007 5:25 pm
by tobik
The smileys modifier works when debug mode is active

Code: Select all

$config['debug'] = true;
IMO this is because caching is disabled in debug mode. The pages will be compiled on any request.

Does this make sense? Maybe this is a bug in the core rather then in Smileys module?

Re: {content|smileys} "Smarty error [plugin] modifier 'smileys' is not implemented"

Posted: Tue Aug 21, 2007 6:13 pm
by tobik
Sorry, I am not a native english speaker. I mean it would be a nice free special.

It is not really important. I played around just for interest.
Thought it could be helpful for somebody who better know this stuff...  ;)

Re: {content|smileys} "Smarty error [plugin] modifier 'smileys' is not implemented"

Posted: Tue Aug 21, 2007 8:31 pm
by tobik
Is this a valid solution? At least it works for me.

1. Insert a file named modifier.smileys.php into the plugins directory.

Code: Select all

<?php
/**
 * Smarty plugin
 * ----------------------------------------------------------------
 * Type:     modifier
 * Name:     smileys
 * Purpose:  replace any text smileys with <img> links to smiley icons
 * Author:   TOBIK
 * ----------------------------------------------------------------
 **/
function smarty_cms_modifier_smileys($string)
{
	// Get access to the smileys module
	$smileys = CMSModule::GetModuleInstance("Smileys");
	if ($smileys != false) 
	{
		// replace text smileys with images 
		$string = $smileys->ReplaceSmileys($string);
	} 
	
	return $string;    
}//end of function
?>

2. Change this in /modules/Smileys/Smileys.module.php

Code: Select all

	...
	function SmartyPreCompile(&$content) {
		// this is now handled by /plugins/modifier.smileys.php
		// $this->smarty->register_modifier("smileys",array(&$this,"SmartyModifier"));
	}
	...
Don't forget to empty the cache in Site Admin > Global Settings

Regards, Tobik

{content|smileys} "Smarty error [plugin] modifier 'smileys' is not implemented"

Posted: Tue Aug 21, 2007 9:30 pm
by tobik
This is a explanation as I understand this issue.

On first page load the Smiley module registers the modifier in Smarty.

Code: Select all

function SmartyPreCompile(&$content) {
		$this->smarty->register_modifier("smileys",array(&[u]$this[/u],"SmartyModifier"));
	}
A reference to this instance of Smileys modules class is registered. The lifetime of the instance ends when the request is finished but the compiled page is kept in cache.

On the next page load the old Smileys module class instance is gone but no new modifier registration is performed until the cache is emptied. The old reference to the gone Smileys class instance throws the error.

That make sense?
Tobik

Re: [solved] {content|smileys} "Smarty error [plugin] modifier 'smileys' is not

Posted: Wed Aug 22, 2007 5:27 am
by cyberman
Thanks for that solution ...