| |
|
| :: |
| Author |
Message |
elturbo
Joined: 15 Jun 2007 Posts: 3
|
Posted: Sat Jun 16, 2007 5:24 pm Post subject: GYM Sitemaps, the XML patch and dynamic XML |
|
|
First of all, nice mods. I've spent a few days installing many of them to a phpBB board I run. Impossible to tell at this point whether SE traffic will improve, but at least many of the concepts are sound.
However, there's one slight issue I'm wrestling with. I installed the GYM Sitemaps mod. As I wanted the sitemap to include all pages on the site, not just the pages on the forum, I installed the GYM Sitemaps XML mod as well. Then I run into a bit of a problem.
The XML mod supposes that you place a static XML file to /mx_ggsitemaps/xml_lists/ and name it in a certain way. My issue is that I the site I run has a nice stack of pages and new pages are added every now and then. Fortunately, the names of all active non-forum pages are easy to get with a simple database query at any time.
So, what I'd like to do is to dynamically create the XML for the sitemap of the site pages. Simple solutions, like writing a PHP-script with an .XML-extension and placing it to /mx_ggsitemaps/xml_lists/ don't seem to work, even if the server parses XML files as PHP.
My bubblegum solution has been to crudely patch ggs_functions.php (in the mx_ggsitemaps/includes/ dir) by inserting something like this in the send_header() function just before return; at the end of the function:
if ( $_GET['xml'] == "site_map-givenname") {
// here I dynamically construct the XML and output it
$this->safe_exit();
}
This works, but is probably far from optimal. Also, it drops all the nice style features all the other sitemaps have, which is a shame.
Any thoughts? Because I'm lazy, I'd like to construct the XML file dynamically. However, I'm sure there are better ways to do this. I'm currently biased towards constructing the page on the fly. While it's a resource hog, making a PHP script that constructs the XML sitemap whenever the site changes doesn't seem as convenient. After all, if I forget to run the script after the site changes, the sitemap becomes out of date.
Anyhow, thanks for the nice mods! |
|
|
| Back to top |
|
 |
|
 |
elturbo
Joined: 15 Jun 2007 Posts: 3
|
Posted: Sat Jun 16, 2007 5:28 pm Post subject: Re: GYM Sitemaps, the XML patch and dynamic XML |
|
|
One other thing: I think there's a slight mistake in the GYM Sitemaps 1.2.0 RC4 mod. To be more specific, line 479 of the gym_sitemapsV1-2-0RC4.txt (installation instructions) should probably read
copy root/language/lang_english/lang_ggs_main.php to language/lang_english/lang_ggs_main.php
instead of
copy root/language/lang_french/lang_ggs_main.php to language/lang_english/lang_ggs_main.php
Easy to figure out (since there is no directory language/lang_french), but might want to fix that for the next version anyhow. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14131
|
Posted: Sat Jun 16, 2007 10:05 pm Post subject: Re: GYM Sitemaps, the XML patch and dynamic XML |
|
|
Thanks for reporting the typo.
Then, about what you want to do, I guess the xml plug-in is not the way to go.
if the web site is using the same db as phpBB, it will be easy, if not, you'll just have to start a new connection.
The GYM sitemaps module is itself modular, in mx_ggsitemaps/includes/, you'll find the function files but as well files like google_forum.php, rss_forum.php and urllist_forum.php
Now if you create a file named google_site.php that follow the few standards of the mod, the content it could generate would be directly be integrated into the sitemapindex and the sitemaps.
Open up googl_forum.php, the file starts with the basic phpBB security check, and is made to only be used by the GGSitemaps class.
This file can use several type of input : sitemap.php?forum and sitemap.php?forum=xx
The forum get var is handled by sitemap.php only because there is a google_forum.php file, if you add a google _site.php file, it will be the same with sitemap.php?site and sitemap.php?site=string (at first)
The get vars are prefiltered in sitemap.php, but the final type must be checked in the plug-in file, to allow both strings and number as values for the GET var.
In google_forum.php, we only deal with numbers thus :
| Code: | // Filter $this->actions['list_id'] var type
$this->actions['list_id'] = intval($this->actions['list_id']); |
Then we check auth and start the main conditions :
| Code: | if ($this->actions['action'] === 'forum') {
// Would be if ($this->actions['action'] === 'site') { in the google_site.php file
//it's a sitemap we can play with more conditions like
// if ($this->actions['list_id'] > 0) { or if ($this->actions['list_id'] > 'string') { in case you deal with string instead
// The else for this one, when list_id = 0 is used to generate a list of all forums, could be categories for a blog
} else {
// It's a sitemapindex call, just send the sitemapindex entrie(s)
// Could be one per categories for a blog, or even on per user
} |
Data & templating :
Rather simple, using sprintf to parse data, since it's faster than straight var parsing :
| Code: | $this->output_data['data'] .= sprintf($this->style_config['Sitemap_tpl'], $forum_url . $phpbb_seo->seo_ext['forum'], $forum_time, 'always', '1.0');
$this->output_data['url_sofar']++; |
As you can see it's simple, first the basic template, always the same, then the url, here using two vars, the last_mod time, change freq and priority.
You can of course use another basic template if you want to drop either of the tags, like priority or whatever.
That's all. If you know a bit how to code and grab datas from the db, it's in the end easy this way. And you enjoy directly the caching and styling from the mod
The same principles applies with rss and urllist.
You'd need to add a rewriterule for the sitemap.php?file=something case, the other one would be directlty handled in case using sitemap-site.xml is ok for you.
You could as well directly implement on off for mod rewritten URLs, using :
| Code: | | if ($this->mod_r_config['mod_rewrite']) { |
Would be synchronized with the main mod rewrite switch.
Or :
| Code: | | if ($this->mod_r_config['mod_r_type'] > 0) { |
To only check if the forum is using mod rewrite, one of the phpBB SEO ones.
This si to make it ON/OFF, the code in google_forum.php handles 4 cases (vanilla + 3 phpbb seo mod rewrites) in one condition within the loop, so it's a bit trickier.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
elturbo
Joined: 15 Jun 2007 Posts: 3
|
Posted: Sun Jun 17, 2007 6:15 pm Post subject: Re: GYM Sitemaps, the XML patch and dynamic XML |
|
|
Thanks for the instructions!
Now everything seems to be running smoothly. I've created google_site.php and moved my code over from ggs_functions.php. It took me a while to figure things out, though . |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14131
|
|
| Back to top |
|
 |
|
|
| Navigation |
Similar Topics |
|
|
|
|
|
|
|