Recent Topics

1 Jan 04, 2007 03:09    

Dunno if that's clear or not, but here's my problem. I wrote a renderer plugin that turns keywords into either acronyms or links. I included a mechanism by which the installer could decide which blog(s) it will be applied to. It works in that if I apply it to blog #2 then posts in any other blog will not have the rendering done, but when I post in those blogs the plugin shows up in the "text renderers" section of the back office. In other words the only thing I've been able to turn off is if it actually renders.

So how can I make a plugin that renders not be included in the list of renderers on the Write tab if the plugin is not going to be used on the blog?

Here's the relevant code:

function GetDefaultSettings() {
	return array(
		'forblogs' => array(
			'label' => T_('Apply to Blogs'),
			'defaultvalue' => '2,3',
			'type' => 'text',
			'note' => T_('comma separated list of blogs, or ALL for all blogs.'),
			'id' => $this->classname.'forblogs',
			),
		);
	}


Then

function RenderItemAsHtml( & $params ) {
	global $blog;
	$for_blogs = explode( ',', $this->Settings->get('forblogs') );
	if( $this->Settings->get('forblogs') != 'ALL' ) {
		if( ! in_array($blog, $for_blogs) ) {
			$apply_rendering = 'never';
			return true;
			}
		}

I tried to apply the "if it's not in the forblogs array and forblogs isn't ALL" elsewhere only to either crash the plugin or see no change on the Write tab.


Form is loading...