Recent Topics

DisplayItemAsHtml called twice

Started by on Jan 12, 2009 – Contents updated: Jan 12, 2009

Jan 12, 2009 05:30    

I ran into a bug in the Disqus plugin that causes the Disqus javascript to be inserted into the post twice because DisplayItemHtml is called twice for posts with a

follow up marker in the post. It seems that it it called once for the first part and once for the follow up.

This is a bit strange, but I could solve the problem if I could tell if I was displaying the first part or the second part of the post, as I only need to add the javascript at the end of the post. Is there a way to do this? I couldn't find an answer immediately as the 'dispmore', 'preview', and 'format' are all constant.

Jan 12, 2009 09:29

That's a smidge of a pita :-S see if this is of any use to you

	function DisplayItemAsHtml( & $params )
	{
		if( $params['dispmore']  )
		{ // lets try and see if we're on the first page
			global $page;
			$content = $params['Item']->get_content_page( $page, 'htmlbody' );
			if( strpos( $content, '<!--more-->' ) !== false )
			{ // we have a possible pre-more condition
				$content = explode( '<!--more-->', $content );
				array_shift( $content );
				$content = implode( '', $content );
				if( $content != $params['data'] )
				{ // we're before more
					pre_dump( false );
					return;
				}
			}
		}
		pre_dump( true );

¥

Jan 12, 2009 15:38

Yet another workaround ;)

function DisplayItemAsHtml( & $params )
{		
	if( $this->form_displayed && $this->form_displayed == $params['Item']->ID ) return;
	
	[DO SMTH]
	
	$this->form_displayed = $params['Item']->ID;
}


Form is loading...

Free CMS – This forum is powered by b2evolution CMS, a complete engine for your website.