Use GYM Sitemaps & RSS in main sites

The GYM Sitemaps & RSS module for phpBB. Sitemaps and RSS feeds for Google Yahoo! and MSN Live, support, add ons etc ...

Moderator: Moderators

Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Thu Jun 25, 2009 6:51 am

I want to use this awesome script for my main site too but the forum and the main site have totally different structures so I really want to know if there's a way to make it work.

I just want to make it simple like the way my main site is. It will be a sitemap with categories being child sitemaps, and entries being items. But I want to use this script's mechanism. dcz could you please guide me through this? Thank you!
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Advertisement

Re: Use GYM Sitemaps & RSS in main sites

Postby dcz » Thu Jun 25, 2009 7:55 am

Have a look at the install file to find out how to move your sitemap.php file (and others) to root level, and then, to the Google XML and TXT modules to see how you can add more content to your sitemaps.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Thu Jun 25, 2009 10:29 am

Thanks for your answer. Actually, that's what I have already done before posting this topic. Since the module is quite complex, I need to ask first. So all I need to do is edit the modules, and nothing more? I hate to ask too much but I kinda need to rush...
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Re: Use GYM Sitemaps & RSS in main sites

Postby dcz » Fri Jun 26, 2009 8:02 am

Not editing it, but rather reading what's said about it in acp to understand what it can do ;)
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Fri Jun 26, 2009 9:10 am

Eh...what do you mean? Sorry about being ignorant :oops:

From what I can understand, the module pulls contents from database such as topics, forum, etc. so if I want to pull my own categories, entries, I have to edit the module, do I?
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Re: Use GYM Sitemaps & RSS in main sites

Postby dcz » Sun Jun 28, 2009 9:11 am

Not exactly.

If you just want to integrate static txt or xml list of url, you can do it using the google TXT and XML modules, and for this you need to read their description in acp.

Then, GYM is very modular. If you know how to code, then you can inspire from the existing modules to rather create a new one than edit an existing one. Modules can have an acp, languages files and a module file that can build many pages, it's mostly a matter of following the naming convention for files and config setting if you use any.

The simplest example are the Google XML and TXT modules, have a look at how they are made :
One file for each in gym_sitemaps/acp/ (for the eventual acp options), gym_sitemaps/modules/ (the files building the output) and language/lang/gym_sitemaps/acp/.

That's all you need to make a module, if you add one, it will appear in the install page of GYM google ACP where you'll be able to activate it (this is done automatically when you fist install gym).

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Sun Jun 28, 2009 11:19 am

Yup! Thank you! While waiting for your response I have already found out how to make this work. Currently I am doing some coding. If I have any trouble I will ask. Thanks again :D
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Wed Jul 01, 2009 5:29 am

Hi!

In the file modules/google_user.php I found some SQL query. I don't see any in modules/google_xml.php so in order to fetch data from other tables I need edit google_user.php, is that right?

You said that I only have to make 3 new files but if the SQL queries are in google_user.php, I have no idea to make main site's sitemap without editing it.

I want to have a main_site.xml inside sitemapindex.xml then inside main_site.xml there are categories and articles.

Thanks!
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Re: Use GYM Sitemaps & RSS in main sites

Postby dcz » Fri Jul 03, 2009 9:20 am

google_user.php was actually a left over that should not have been added to the package (I just updated it to remove that file).

The idea is that you should create a new file, like google_site.php and then add the required code in it. There is no SQL statement in google_xml.php because it's only importing flat xml sitemap files, for what you want to do, you should still inspire from it since it's a very simple example of how thing should be done. google_forum.php is a bit more complicated, since it deals with more than one sitemap, but the framework is the same.

As you can see, google_forum.php will correspond to sitemap.php?forum and sitemap.php?forum=(forum_id|announces), it will be the same with google_site.php, will be accessed through sitemap.php?site and sitemap.php?site=something

The site GET variable will be used to address the query to the google_site.php module, in ti, you'll be able to play with the site GET value through $this->actions['module_sub'] to build the sitemap content.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Sat Aug 22, 2009 4:10 pm

Hi! Long time no see!

I have made a new module called google_site.php with necessary acp files. It has shown up and I have installed it successfully.

However, I am still wondering two things:

1. There are some config variable, like this: url_config['google_forum_tpl'] ( and many other ) which I do not know where they are stored. In the database only 12 pages of config vars and they just don't appear there.

2. As I understand, when I request:http://www.domain.com/sitemapindex.xml, after URL rewritten, it goes to sitemap.php, and then initiates the class gym_google(). But I do not know wherein the file gym_google.php you call the google_forum.php module.

I am still confused about the use of module_main, module_sub, module_sep, etc.

These below rewrite rule, how do I use them to, ah, call google_site.php module instead of google_forum.php?
Code: Select all
RewriteRule ^sitemapindex\.xml(\.gz)?$ /sitemap.php?gzip=$1 [QSA,L,NC]
RewriteRule ^[a-z0-9_-]+-([a-z]{1})([0-9]+)\.xml(\.gz)?$ /sitemap.php?module_sep=$1&module_sub=$2&gzip=$3 [QSA,L,NC]
RewriteRule ^([a-z0-9_]+)-([a-z0-9_-]+)\.xml(\.gz)?$ /sitemap.php?$1=$2&gzip=$3 [QSA,L,NC]


Thanks a lot!
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Sun Aug 23, 2009 12:31 pm

Oh man got it to work! :D

After struggling with the code now it works pretty well I think. But I still need someone who can check if my sitemap has any problem. dcz could you please check your IM?

The GYM module is great lol :lol:
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Re: Use GYM Sitemaps & RSS in main sites

Postby dcz » Sun Aug 23, 2009 1:44 pm

Happy you like it :D

So about the framework, the sitemap are built using the gym_google class, but this class extends the gym_sitemaps one (gym_sitemaps.php). Every output type (RSS, sitemap, html) uses it's own class that extends the core one.
The google_forum_tpl entry is defined in the gym_google::init_url_settings method, but google_default is in gym_sitemaps class.

About adding modules, it's actually pretty easy once you've got into the code deeper, no rewriterules should be required, since, from your example, google_site.php will already be made available through sitemap.php?site(=something_eventually) which should correspond to site(-something_eventually).xml when url rewritten.
Or, if you're using title injection, then, sitemap.php?site=IDcan as well correspond to title-{delimiter}ID.xml, the framework will then determine the module to load from the delimiter, which thus needs to be properly declared in the setup_phpbb_seo_class.php file (or the phpbb_seo_class_light.php when used standalone) in the phpbb_seo::seo_delim array.
It's dealt with in gym_google.php :
Code: Select all
      // Take care about module categories urls, assuming that they are of the proper form
      // title-sepXX.xml
      // assuming that phpbb_seo seo_delim array is properly set.
      if (empty($this->actions['module_main']) && empty($this->actions['module_sub']) && !empty($_REQUEST['module_sep']) && !empty($_REQUEST['module_sub'])) {
         if ($module = @array_search('-' . $_REQUEST['module_sep'], $phpbb_seo->seo_delim)) {
            $this->actions['module_main'] = $module;
            $this->actions['module_sub'] = (int) $_REQUEST['module_sub'];
         }
      }


The forum delimiter is -f, all you need to do when adding more is to keep the hyphen followed by one character (no digits).
module_main is the entry holding the module (type is defined by the file called, eg gymrss.php, sitemap.php or map.php), module_sub holds the eventual value of the module_main get variable :
Code: Select all
sitemap.php?forum=54 <=> sitemap.php?module_main=module_sub


About point 2, the google_forum class is called in gym_google, as any module would :
First we determine if we're going to build a sitemap or a sitemapindex, eg sitemap.php is the sitemapindex (no or non valid module_main sent)
Code: Select all
      if ( empty($this->actions['module_main']) ) { // SitemapIndex
         $this->google_sitemapindex();
      } else { // Sitemap
         $this->google_sitemap();
      }


Then, for the sitemapindex, we use :
Code: Select all
      // start the modules
      $this->load_modules('sitemapindex');

gym_sitemaps::load_modules will load all available modules from the used output type and execute their sitemapindex method.
For sitemaps, we do the same but only load one module :
Code: Select all
      // start the module
      $module_class = $this->actions['action_type'] . '_' . $this->actions['module_main'];
      $this->load_module($module_class, 'sitemap');

$module_class = google_forum for the google_forum class, and the method used here will be the sitemap one.

So you have the whole scenario here, a dedicated class (rss, sitemaps, html) extending a core class (gym_sitemaps) which loads modules. GYM modules are pretty similar to phpBB acp module, eg a class implementing a master class by reference.
And all module calls are passing through gym_sitemaps::load_module and gym_sitemaps::load_module :
Code: Select all
   /**
   * load_modules ( $module_type, $method = '' ).
   * loads all modules for a given action_type
   * Optional, starts a method
   * @access private
   */
   function load_modules( $method = ''  ) {
      foreach ( $this->actions['action_modules'] as $module ) {
         $this->load_module( $this->actions['action_type'] . "_$module", $method);
      }
   }
   /**
   * load_module ( $module_class, $method = '' ).
   * loads a module for a given action
   * Optional, starts a method
   * @access private
   */
   function load_module( $module_class, $method = '', $return = false ) {
      global $phpEx;
      $module_file = $this->path_config['gym_path'] . 'modules/' . $module_class . '.' . $phpEx;
      if ( !empty($this->gym_config[$module_class . '_installed']) && file_exists($module_file) ) {
         include_once($module_file);
         if (class_exists($module_class)) {
            $gym_module = new $module_class($this);
            if ( !empty($method) && method_exists($gym_module, $method)) {
               $gym_module->$method();
            }
            if ($return) {
               return $gym_module;
            }
         }
      } else {
         $this->gym_error(500, '', __FILE__, __LINE__);
      }
   }


Hope this helps. Feel free to ask for more details, and why not to share your dev if it's applicable.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Mon Aug 24, 2009 5:29 am

Yes!!! That's exactly what I figured out after struggling with the code, you know I'm still a newbie at PHP OO.

Anyway, I will surely post my dev if someone needs it since it would take some time :lol:

Btw, I have a question about styling the error page. Normally if you have a sitemap like this:

-www.domain.com/a-forum-fid.xml

and that forum has some kinds of errors, it will display an error page with proper styling. However, if we have a sitemap like this:

-www.domain.com/cat/a-category.xml (like in the PM I sent U : P)

and that category has errors, it will display wrong style, i.e. no style at all. I know this is because of the URL that breaks the relative path to the stylesheet. Is there anyway to fix this?

Thanks dcz!
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Re: Use GYM Sitemaps & RSS in main sites

Postby dcz » Mon Aug 24, 2009 8:24 am

The error page is built in includes/functions.php (function msg_handler) and does not need an external css. So I assume that the layout is just broken by the fact some error message (php notice) was displayed before msg_handler sent the html head tag.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21429
Joined: Fri Apr 28, 2006 9:03 pm

Re: Use GYM Sitemaps & RSS in main sites

Postby iwanttobelieve » Mon Aug 24, 2009 10:56 am

But the problem is, it does require an external stylesheet.

I've figured out the script uses the function msg_handler as you said, but it calls for case E_USER_NOTICE: right? And that calls for message_body.html which also includes overall_header.html and the likes. Overall_header needs an external css like for the main forum, doesn't it?

Normally with SEO mod, we have this in overall_header.html: {SEO_BASE_HREF} but it doesn't appear with E_USER_NOTICE which breaks the style I think.

So what do you think?
iwanttobelieve
PR1
PR1
 
Posts: 123
Joined: Sun Jun 14, 2009 5:37 am
Location: Somewhere I don't belong lol

Next

Return to GYM Sitemaps & RSS

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 4 guests