Google Sitemap

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
markoehl
Posts: 50
Joined: Thu 29. Dec 2005, 11:08
Location: Zürich
Contact:

Google Sitemap

Post by markoehl »

Implemented in Version phpwcms 1.2.8
Last edited by markoehl on Mon 4. Dec 2006, 23:18, edited 8 times in total.
User avatar
Fulvio Romanin
Posts: 394
Joined: Thu 4. Dec 2003, 11:12
Location: Udine, Italy
Contact:

Post by Fulvio Romanin »

a demo, please? :D
Completeness is reached through subtraction, not through addition
squidi
Posts: 143
Joined: Sat 17. Jan 2004, 13:49
Location: Berlin

Post by squidi »

hi markoehl,

nice work ! works with phpwcms 1.2.6 ( 14.12.05 ) :P don't forget chmod 666 to sitemap.xml ...

squidi
Glovebox
Posts: 15
Joined: Fri 11. Nov 2005, 14:41

Post by Glovebox »

This doesnt support re-written urls?
Buletti
Posts: 43
Joined: Tue 27. Sep 2005, 10:51
Location: Hamburg / Berlin / Germany

Sitemaps

Post by Buletti »

Hi Folks,
if i use thise sitemap hack and i transer it to google, google says.

this format is not supported

Any ideas ?
markoehl
Posts: 50
Joined: Thu 29. Dec 2005, 11:08
Location: Zürich
Contact:

Re: Sitemaps

Post by markoehl »

Buletti wrote:Hi Folks,
if i use thise sitemap hack and i transer it to google, google says.

this format is not supported

Any ideas ?
Can you post the link of the sitemap.xml file?

Or checkout new version Get the new Files http://www.pagewerkstatt.ch/phpwcms_mod_sitemap.zip
Last edited by markoehl on Thu 5. Jan 2006, 00:09, edited 1 time in total.
markoehl
Posts: 50
Joined: Thu 29. Dec 2005, 11:08
Location: Zürich
Contact:

Post by markoehl »

Glovebox wrote:This doesnt support re-written urls?
As much I know rewritten urls works only for the structure. This scrpt is reading the content from phpwcms_article.. But I will have a closer look at that..
arkon
Posts: 14
Joined: Mon 8. Mar 2004, 13:27

Post by arkon »

two suggestions:

1. in googleSitemap.inc.php on line 62 after

Code: Select all

	function generateSitemap()
	{
i would replace

Code: Select all

		$strSitemap = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
		$strSitemap .= "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">\n";
with

Code: Select all

		$strSitemap = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
		$strSitemap .= "<?xml-stylesheet type=\"text/xsl\" href=\"gss.xsl\"?>\n";
		$strSitemap .= "<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd\">\n";
this will format your sitemap in a nice way.

2. in article.editcontent.inc.php on line 33 i would add at the end of the sql-statement

Code: Select all

WHERE article_public=1 AND article_aktiv=1 AND article_nositemap=1
so it saves only active and public articles and articles that are marked for the phpwcms-sitemap-module.

the correct line would be

Code: Select all

$sql = "SELECT article_id, article_cid, date_format(article_tstamp, '%Y-%m-%d %H:%i:%s') AS article_date FROM ".DB_PREPEND."phpwcms_article WHERE article_public=1 AND article_aktiv=1 AND article_nositemap=1;";
markoehl
Posts: 50
Joined: Thu 29. Dec 2005, 11:08
Location: Zürich
Contact:

Update google sitemap

Post by markoehl »

Thanx Mate
great feedback. I implemented this new code and added also the gss files. Looks much better now!!

Get the new Files http://www.pagewerkstatt.ch/phpwcms_mod_sitemap.zip
Glovebox
Posts: 15
Joined: Fri 11. Nov 2005, 14:41

Post by Glovebox »

markoehl wrote:
Glovebox wrote:This doesnt support re-written urls?
As much I know rewritten urls works only for the structure. This scrpt is reading the content from phpwcms_article.. But I will have a closer look at that..
Thanks, please let us know.
squidi
Posts: 143
Joined: Sat 17. Jan 2004, 13:49
Location: Berlin

Post by squidi »

hi,

problem with a local installation ( xampplite - XJ! )

Code: Select all

Fatal error: URL http://localhost:8888/phpwcms/ not valid. Must be http[s]://[some.]domain.ext/ in C:\xampplite\htdocs\phpwcms\include\inc_lib\googleSitemap.inc.php on line 24
squidi
Last edited by squidi on Sat 14. Jan 2006, 13:55, edited 2 times in total.
squidi - open your eyes before you dance
markoehl
Posts: 50
Joined: Thu 29. Dec 2005, 11:08
Location: Zürich
Contact:

Post by markoehl »

squidi wrote:hi,

problem with a local installation ( xampplite - XJ! )

Code: Select all

Fatal error: URL http://localhost:8888/phpwcms/ not valid. Must be http[s]://[some.]domain.ext/ in C:\xampplite\htdocs\phpwcms\include\inc_lib\googleSitemap.inc.php on line 24
squidi
To test with a local installation you have do replace code
if (!preg_match("/^https?:\/\/[a-z]([a-z0-9-.]+)+?.[a-z]+\/$/i", $strBaseURL))
{
trigger_error("URL {$strBaseURL} not valid. Must be http://[some.]domain.ext/", E_USER_ERROR);
}
else
{
$this->strBaseURL = $strBaseURL;
}

with
$this->strBaseURL = $strBaseURL;

Regards
volkman
Posts: 179
Joined: Wed 13. Jul 2005, 12:52
Location: Hamburg, Germany

Post by volkman »

@arkon
I added

Code: Select all

AND article_deleted=0
in article.editcontent.inc.php on line 33 to avoid listing deleted articles in the sitemap

volkman
markoehl
Posts: 50
Joined: Thu 29. Dec 2005, 11:08
Location: Zürich
Contact:

Post by markoehl »

volkman wrote:@arkon
I added

Code: Select all

AND article_deleted=0
in article.editcontent.inc.php on line 33 to avoid listing deleted articles in the sitemap

volkman
Thanx. I modified the script too....
volkman
Posts: 179
Joined: Wed 13. Jul 2005, 12:52
Location: Hamburg, Germany

Alias ind sitemapfile

Post by volkman »

I wanted the aliasname in the sitemapfile instead of /index.php?id=92,0,26,0....
So i modified the SQL-Statement in article.editcontent.inc.php. I am selecting fields from two tables (phpwcms_article and phpwcms_articlecat). If article_cid (from phpwcms_article) and acat_id (from phpwcms_articlecat) are the same fetch the acat_alias, thats it.

Code: Select all

$sql = "SELECT acat_id, acat_alias, article_cid, date_format(article_tstamp, '%Y-%m-%d %H:%i:%s') AS article_date ";
$sql .= "FROM ".DB_PREPEND."phpwcms_articlecat, phpwcms_article WHERE (acat_id = article_cid) AND article_public=1 AND article_aktiv=1 AND article_nositemap=1 AND article_deleted=0;"; 
if($result = mysql_query($sql, $db)) {
	while($row = mysql_fetch_row($result)) {
		$oSitemap->addEntry(
			array('loc' => 'index.php?'.$row[1].'',
				'lastmod' => $row[3],
				'changefreq' => 'monthly',
				'priority' => '0.8'));
	}
	mysql_free_result($result);
}
We only need $row[1] (the alias) and $row[3] (date of modification).

After editing the file the map looks like this:

Code: Select all

<loc>http://www.yourdomain.de/index.php?sitemap</loc>
<lastmod>2006-03-05T18:15:30+00:00</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>http://www.yourdomain.de/index.php?kompetenznetz</loc>
<lastmod>2006-03-14T10:07:21+00:00</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>http://www.yourdomain.de/index.php?patient</loc>
<lastmod>2006-03-05T16:33:36+00:00</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
Hope that helps,

volkman
Post Reply