Page 1 of 1

Gsitemap with my module

Posted: Tue Aug 18, 2009 10:55 am
by gap_tooth_clan
Hi I have been trying to integrate my module pages into the gsitemap.php Just been running into some problems.

I was trying to include class.module.inc.php but this creates a conflict trying to redefine cmsobject.

To make this work i need to use these two functions:

GetPreference

CreateLink

Any ideas on how to get this to work.

Re: Gsitemap with my module

Posted: Tue Aug 18, 2009 4:17 pm
by viebig
I think there is not a standard way to fix it, but:

You can check is the object is defined in the core files that instantiate this object, use something like

Code: Select all

if (!is_object($obj)
{
$obj - new Obj()
}

Re: Gsitemap with my module

Posted: Fri Aug 21, 2009 9:08 am
by gap_tooth_clan
Ok that is a pain in the butt. Maybe this is something that can or should be added to the CMS, it would open up modules to be added to the google site map.

I am pretty sure this would help users sites rankings especially if news could be added to this.

Re: Gsitemap with my module

Posted: Fri Aug 28, 2009 6:00 pm
by plger
Hi,
(I will assume your gsitemap.php is the Google Sitemap Plugin by Noll & co., and I will also assume that I understand what you mean)

The php file loads the basic include file, which also means $gCms, so you can access any module using :

Code: Select all

if(  isset($gCms->modules[$modulename])
	&& $gCms->modules[$modulename]["active"]
	&& $themodule = $gCms->modules[$modulename]["object"]
	){
	// your code
}
or (not tested for error notices, but should be ok)

Code: Select all

if( $themodule = $gCms->GetModuleInstance[$modulename] ){
	// your code
}
Where "your code" could be a call to an action if your module has, like mines, an action to output a sitemap :

Code: Select all

$themodule->DoAction("sitemap", "", $params);
or otherwise acces the tables manually :

Code: Select all

$db = $gCms->GetDb();
$query = "SELECT news_id, news_title FROM ".cms_db_prefix()."module_news"; // just an example...
$dbresult = $db->Execute($query);
while ($dbresult && $row = $dbresult->FetchRow()){
	// print out your <url> tag
}';
Pierre-Luc