Topic on Project:Support desk

how to check is it main page

1
Anyhowputx (talkcontribs)

Hi guys,

I am trying to check if the current title is on the main page. If it is on the main page, don't show the like icon, else show the like icon. (Meaning I want to show the like icon on every page except the main page)

Currently my code to check the main page is like this

$wgExtensionFunctions[] = 'wfSetupLikes';
/*
Some other codes 
*/
function wfSetupLikes()
{
    global $wgLikes;
	if (!($this->getTitle()->isMainPage()))
	{
		  $wgLikes = new Likes;
	}
	else
	{
		//do nothing
	}
}

But php error log is giving me the error(PHP Fatal error: Using $this when not in object context) .

Thanks for all assistance!

Reply to "how to check is it main page"