How to use the same style for sitemap as of forum.

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

Moderator: Moderators

Postby digital1 » Mon Jul 21, 2008 6:57 pm

@dcz & @jonli447

Thanks for the support and guidance. I am looking forward to post you gona make in the field of customization and styling of sitemap and rss feed.

digital1
Ashu
digital1
PR0
PR0
 
Posts: 54
Joined: Fri Oct 26, 2007 6:53 am
Location: India

Advertisement

Postby jonli447 » Mon Jul 21, 2008 8:23 pm

@digital1 - No problem :)

I have added the switch as dcz mentioned. I made caching dependent on the script, i.e. if "dynamic = true" then XSL are created in real time, not cached. I can't see why CSS should not be cached, so I left that intact.

The issue I'm currently working on is where dcz mentioned about adding the template variables w/o starting a new session. That part is actually the hard part. If we're going to keep language localization in tact, this feat is very tricky, but doable.

Thankfully, most of the variables I can just copy straight out of functions.php. The ones involving the SID is not so easy.

I can post what I've done as far as modifying gym_sitemaps.php if people want to see and help carry on. I'd want to wait for dcz to give me permission though, as I'm not sure if he'll like creating a public fork of his project, especially so soon.

Cheers
jonli447
 
Posts: 17
Joined: Wed Oct 31, 2007 11:15 pm

Postby dcz » Tue Jul 22, 2008 9:20 am

@jonli447

Well I was thinking that we could eventually include, if you want of course, your addition to the official mod rather than forking, which as you said is quite early at this stage. It could be an extra option.

About session IDs, it's a bit more complex than I first though. At least if we want to keep the script light enough.
The heavy way would be to start a real session in gym_style.php and to include common.php. If you take a look at the regular phpBB styling process, you'll see that the logged in out status is only retrieved by the SID sent in the style-sheet link. So that only a query on session table is enough to determine the online offline state.

Problem here is that this particular link is cached with the rest of the xml source code.

A possible solution for this would be to use an extra opttion to for example replace the style link with something easy to later parse, such as {XSL_LINK}, in gym_google.php :
Code: Select all
      if ($this->gym_config['google_xslt']) {
         $this->style_config['xslt_style'] = "\n" . '<?xml-stylesheet type="text/xsl" href="' . $phpbb_seo->seo_path['phpbb_url'] . 'gym_sitemaps/gym_style.' . $phpEx . '?action-google,type-xsl,lang-' . $config['default_lang'] . ',theme_id-' . $config['default_style'] . '" ?>';
      }


This tag could be later replaced in gym_output.php, in cache_output and in otf_output. Problem here is it would be a serious overload too, since we would have to first load all the cached content and then perform the replace to add the current user's SID in the style sheet link. With gunzip it would be worst since you'd need to additionally uncompress replace and re compress ...

The alternative would be to only cache the content and dynamically generate the headers each times, it's doable, and would be faster, but it would not allow us to use the readgzfile() function which is really fast when it comes to sending gunzip files.

Or for now you could only offer dynamic support for user with cookies (the vast majority) and then retrieve the SID from the cookie and start from there. I in the end think that it would be the simplest and lightest solution.
Take a look at includes/sessions.php to see how cookies are retrieved, the sessions and user fucntion are not included in gym_style, but you could be inspired by the way it is done ;)

++
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: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Postby jonli447 » Tue Jul 22, 2008 2:17 pm

Thanks dcz You've given me a lot to think about. As for my modifications, I'll pass them to you first, and then you can decide if/how you want to post it here. I know how annoying it can be when people start to fork your project, on your site. IMO, a fork is not necessary as the modifications should be "light" as possible.

Hehe, yesterday I spent perhaps more time on this project that I had wished. :-) I took me three logical tries before I started getting somewhere.

Here's where I'm at currently. I am able to pull all the localization variables needed (i.e. L_MEMBERLIST). Additionally, there are 5 variables that I have created that emulate the dynamic variables in the phpbb template system. To keep the naming system the same, they are:

[list=]S_IS_BOT
S_DISPLAY_MEMBERSHIP
S_REGISTER_ENABLED
S_USER_LOGGED_IN
S_DISPLAY_SEARCH[/list]

I've managed to pull S_REGISTER_ENABLED (from the config) and S_USER_LOGGED_IN quite easily and correctly. The other three are tricky, as you mentioned, as they rely on functions in common.php and session.php. I'm still trying to think about the best way to the remaining three variables efficiently and simply (I'd rather not have to start an entire session).

Now, here's where we may differ in development style. As you mentioned, XSL is not very easy to make dynamic. Currently, instead of using XSL to handling the logic, I placed a preprocessing routine to determine what should be displayed. This mimics the prosilver template system (i.e. if S_IS_BOT != true and S_USER_LOGGED_IN == true, display memberlist). This probably does not belong in this part of the script, but rather a separate php file. Otherwise, styling would be rather limited (you'd have to edit the GYM style.php file instead of a template file to style). For now, I'm keeping it here, but it shouldn't be difficult to place an include to a template php file instead.

So, we're getting there. Once I can efficiently pull all five of the control variables, the logic should be sound. Again, currently, the template part of the model works as such:

gym_style.php calculates 5 control variables > 5 variables determine how to set various link template tags I've created (i.e. {MEMBERLIST}). The XSL script contains the template tags, like {MEMBERLIST}, and if gym_style.php enables the link, the tag will be replaced with the link (it's added into the $replace array), otherwise the tag is set to '' and thus is essentially erased.

Hopefully this is sound to you.

@dcz - please PM me with instructions how to send you[/list] the code if you want to see it before it's shared publicly. Thanks.
jonli447
 
Posts: 17
Joined: Wed Oct 31, 2007 11:15 pm

Postby dcz » Tue Jul 22, 2008 2:53 pm

I would love to see some code now, I could give you more precise hints.

You can PM or post a link to a zip file, and I'll test it if you wish. If you agree and if we end up with something good, we'll include in the mod with proper credits since it's a pretty universal and optional feature, it's the good time to do it before we stabilize the amount of features in the RC versions.

++
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: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Postby dcz » Thu Jul 24, 2008 8:14 am

All right, I took a look at you gym_style.php file.

I think we can do most of what you want without passing through common.php, and include so many script.

I'll see what I can do for this later this week.

In case you'll be working on it, here is how I think SID should be retrieved to bypass the full story :
Code: Select all
$theme_id = isset($_GET['theme_id']) ? intval($_GET['theme_id']) : '';
$sid = '';
// Grab SID from cookie
if (isset($_COOKIE[$config['cookie_name'] . '_sid']) {
   $sid = request_var($config['cookie_name'] . '_sid', '', false, true);
}
// fall back to GET & POST
if (empty($sid)) {
   $sid = request_var('sid', '');
}
// Minimal check
if (strspn($sid, 'abcdefABCDEF0123456789') !== strlen($sid)) {
   $sid = '';
}


As well, as a minimal coding guideline, I suggest you use apos when calling array keys :

Code: Select all
$lang['MEMBERLIST']


and not :

Code: Select all
$lang[MEMBERLIST]


This is a small thing, but it ensure that MEMBERLIST is not a constant.

++
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: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Postby jonli447 » Mon Jul 28, 2008 3:57 am

@dcz, Thanks, I've managed to fix gym_style.php for the most part. However, as you noticed, I did pass everything through common.php (though I was able to cut some garbage out). I'll upload a new version for you to check out.

I agree that this could probably be accomplished without passing through common.php. The part that was tricky was obtaining the login status still.

Anyhow, let me know what you think.
jonli447
 
Posts: 17
Joined: Wed Oct 31, 2007 11:15 pm

Re: How to use the same style for sitemap as of forum.

Postby foodcartnegosyo » Tue Jan 11, 2011 3:31 am

ok.. sorry guys,

I can't really understand how you manage to change the layout of sitemapindex and rss. I'm no computer geek or code master. :(

It would be really nice if their is guide, how to pull the vars as menioned by jonli447. :?
foodcartnegosyo
 
Posts: 5
Joined: Mon Jan 10, 2011 2:58 pm

Previous

Return to GYM Sitemaps & RSS

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 10 guests