Gsitemap with my module

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
gap_tooth_clan

Gsitemap with my module

Post 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.
viebig

Re: Gsitemap with my module

Post 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()
}
gap_tooth_clan

Re: Gsitemap with my module

Post 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.
User avatar
plger
Forum Members
Forum Members
Posts: 196
Joined: Wed Oct 15, 2008 10:38 am

Re: Gsitemap with my module

Post 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
Post Reply

Return to “Developers Discussion”