 |
boardom b2 message board
|
View previous topic :: View next topic |
Author |
Message |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Wed Sep 25, 2002 5:52 pm Post subject: /archives/p/X instead of /?p=X (experimental) |
|
|
Preliminary note
Don't try this if you're a newbie. This is not newbie-proof.
This is only experimental, and may break with some template tags, so report problems with it here but don't fill them as bugs.
It requires 0.6pre5, Apache (untested on Apache 2 so far), and the permission to use a .htaccess in your blog's directory.
Intro
As some of you noticed, on tidakada.com and indiboi.com the permalinks look like this: /archives/p/1877/c/1 instead of /?p=1877&c=1.
This helps indexing in search engines (though Google hates tidakada.com for no particular reason, indiboi.com is being indexed a lot lately thanks to the change to forward slashes URLs).
It's a feature that I added to b2, but didn't document because it isn't straight-forward to use and I wouldn't like to trouble-shoot people's problems with it (hence the above Note).
How-To
1. When you unzipped b2 0.6pre5, you may have noticed a new directory called b2-tools. In this directory, there are 2 files that you'll copy to your blog's directory: 'archives' and 'example.htaccess'.
Although I make reference to 'archives', you can rename 'archives' into something else, just remember not to give it a file extension.
2. Rename 'example.htaccess' into '.htaccess', or if you already have a .htaccess file copy the content of example.htaccess into your existing .htaccess file.
3. Open b2config.php, and find these three lines:[php:1:8b0f0aed45]$querystring_start = '?';
$querystring_equal = '=';
$querystring_separator = '&';[/php:1:8b0f0aed45]
Change all the values to '/', like this:[php:1:8b0f0aed45]$querystring_start = '/';
$querystring_equal = '/';
$querystring_separator = '/';[/php:1:8b0f0aed45]
4. Also in b2config.php, you must have this: [php:1:8b0f0aed45]$blogfilename = 'archives';[/php:1:8b0f0aed45]
5. If your previous blog filename wasn't 'index.php', then edit the 'archives' file, changing this line to put the correct filename:[php:1:8b0f0aed45]include('./index.php');[/php:1:8b0f0aed45]
6. Upload your .htaccess, 'archives', and b2config.php files, and you're done. Now you've got this warm fuzzy feeling, so typical of forward slashes.
Troubleshooting
If you have any problem or question with this method, please state it here and don't fill it as a bug.
Last edited by michel v on Wed Sep 25, 2002 8:19 pm; edited 1 time in total |
|
Back to top |
|
 |
imeridian
Joined: 12 Feb 2002 Posts: 191
|
Posted: Wed Sep 25, 2002 6:09 pm Post subject: |
|
|
There are two changes that I needed to blend the new url style in.
In b2archives.php (I think this will be fixed soon anyway):
approx line 17
Code: | $archive_link_m = "$siteurl/".$blogfilename."?m="; # monthly archive |
---becomes---
Code: | $archive_link_m = "$siteurl/".$blogfilename."/m/"; # monthly archive |
and... to use the previous_post and next_post edit b2template.functions.php:
approx line 357
Code: | $string = '<a href="'.$pagenow.$querystring_start.'p'.$querystring_equal.$p_id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1">'.$previous;
| --becomes---
Code: | $string = '<a href="/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$p_id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1">'.$previous;
|
approx line 402
Code: |
$string = '<a href="'.$pagenow.$querystring_start.'p'.$querystring_equal.$p_id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1">'.$next;
| ---becomes-- Code: |
$string = '<a href="/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$p_id.$querystring_separator.'more'.$querystring_equal.'1'.$querystring_separator.'c'.$querystring_equal.'1">'.$next; |
|
|
Back to top |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Wed Sep 25, 2002 7:56 pm Post subject: |
|
|
Thanks for the information, it's now fixed on CVS
I'll re-release pre5 tonight anyway, as I fixed a nasty bug in Pingback. |
|
Back to top |
|
 |
sidcarter
Joined: 18 Sep 2002 Posts: 8
|
Posted: Sat Sep 28, 2002 11:07 am Post subject: CSS and template not working using archives |
|
|
Hi,
I am unable to get this with my setup, as in the template seems to go for a toss when I click on the archives link. I have followed the 6 steps. copied the files into the main b2 dir, changed b2config.php and stuff. No luck.
I am using the this from the **latest** CVS |
|
Back to top |
|
 |
imeridian
Joined: 12 Feb 2002 Posts: 191
|
Posted: Sat Sep 28, 2002 11:13 am Post subject: |
|
|
Make your css import absolute... that is, make it /your.css instead of just being your.css. |
|
Back to top |
|
 |
koski
Joined: 22 Jun 2002 Posts: 16
|
Posted: Sat Sep 28, 2002 2:00 pm Post subject: |
|
|
in file b2-include/b2template.functions.php, over the line 269 (get_the_content function), where it sais:
Code: | $file=$HTTP_SERVER_VARS['PHP_SELF']; |
I had to change to:
to make the (more...) working correctly.
Hope it can help you. |
|
Back to top |
|
 |
koski
Joined: 22 Jun 2002 Posts: 16
|
Posted: Sat Sep 28, 2002 4:50 pm Post subject: |
|
|
I've migrated all my links to the new (experimental) style and all works ok, but i have some hack in separate files.
If you have something similar or you are using b2commentspopup, b2trackbackpopup, b2pingbackspupup you will see that they don't work correctly.
NOTE: they don't work ONLY if you have modified the functions comments_popup_link, trackback_popup_link and pingback_popup_link to use $querystring_start, $querystring_equal, $querystring_separator.
ok, the solution is simple, add the next code (you can obtain that code from the 'archive' file) at the begining of those files and all will go fine.
Code: | $qsdfgh = $_SERVER['REQUEST_URI'];
$ghjklm_array = array (
'm', 'p', 'posts', 'w', 'c', 'cat', 'withcomments', 's',
'search', 'exact', 'sentence', 'poststart', 'postend',
'preview', 'debug', 'calendar', 'page', 'more', 'tb', 'pg'
)y
for ( $i = 0; $i < count( $ghjklm_array ); $i++ ) {
$opbvar = $ghjklm_array[$i];
if ( preg_match( "#/$opbvar/(.+?)/#", $qsdfgh, $ghjklm ) ) {
$$opbvar = str_replace( "/$opbvar/", '', $ghjklm[0] );
$$opbvar = str_replace( '/', '', $$opbvar );
}
elseif ( preg_match( "#/$opbvar/(.+)#", $qsdfgh, $ghjklm ) ) {
$$opbvar = str_replace( "/$opbvar/", '', $ghjklm[0] );
}
} |
If anybody knows a better way, please let me know. |
|
Back to top |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Sat Sep 28, 2002 9:36 pm Post subject: |
|
|
koski wrote: | NOTE: they don't work ONLY if you have modified the functions comments_popup_link, trackback_popup_link and pingback_popup_link to use $querystring_start, $querystring_equal, $querystring_separator.
ok, the solution is simple, add the next code (you can obtain that code from the 'archive' file) at the begining of those files and all will go fine. |
Or just do not modify the functions *_popup_link and it will be fine |
|
Back to top |
|
 |
Bluevox
Joined: 29 Sep 2002 Posts: 1
|
Posted: Sun Sep 29, 2002 2:09 am Post subject: |
|
|
This feature had me completely sold on B2 and works like a charm. Thank you!!!  |
|
Back to top |
|
 |
koski
Joined: 22 Jun 2002 Posts: 16
|
Posted: Sun Sep 29, 2002 10:44 am Post subject: |
|
|
michel you are right. possibly the best is not to modify that functions but I wanted to give all my links the same look, it's all. It is the only reason for making these changes and I posted here if it could hep anybody. It's only a make-up question. ;) |
|
Back to top |
|
 |
koski
Joined: 22 Jun 2002 Posts: 16
|
Posted: Mon Sep 30, 2002 2:51 am Post subject: |
|
|
in the 0.6 version I found that in the file b2comments.post.php over the line 104 you have:
Code: | $notify_message .= $siteurl.'/'.$blogfilename.'?p='.$comment_post_ID.'&c=1'."\r\n\r\n"; |
and it should be:
Code: | $notify_message .= $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal.$comment_post_ID.$querystring_separator.'c'.$querystring_equal.'1'."\r\n\r\n"; |
Last edited by koski on Mon Sep 30, 2002 4:42 am; edited 1 time in total |
|
Back to top |
|
 |
lousypoet
Joined: 09 Aug 2002 Posts: 72 Location: Atlanta, GA
|
Posted: Mon Sep 30, 2002 4:04 am Post subject: |
|
|
also the variable $author needs to be stated in the qsdf array thing. if you just add it to the array, you can do things like /archives/author/3 and get the posts of author #3. I guess it just got left out ... |
|
Back to top |
|
 |
Edlef
Joined: 16 Mar 2002 Posts: 71
|
Posted: Tue Oct 08, 2002 8:57 am Post subject: 8-( |
|
|
I like this feature, but i didnt get it to work correctly with the last version. On some places there are errors....
I think i have to wait for the version 1 of b2?  |
|
Back to top |
|
 |
plazz2000
Joined: 01 Apr 2002 Posts: 40 Location: Cork, Ireland
|
Posted: Thu Oct 10, 2002 8:10 pm Post subject: globals? |
|
|
What does this part of .htaccess do?
Code: | # this will make register globals off in b2's directory
# just put a '#' sign before these three lines if you don't want that
<IfModule mod_php4.c>
php_flag register_globals off
</IfModule>
|
What is "register globals"?
I had a file called site.php on my website with this code in it: Code: | include ("content/$page.php"); ?> | so I could enter site.php?page=downloads
But this stopped working when register globals was switched off so I had to # out those lines in .htaccess.
If "register_globals=off" is important, how do I get my site.php file to work with them off? |
|
Back to top |
|
 |
imeridian
Joined: 12 Feb 2002 Posts: 191
|
Posted: Thu Oct 10, 2002 8:22 pm Post subject: |
|
|
Please read this regarding security concerns when managing your content in such a way.
Google will also tell you quite a bit about what register globals is... it is important for something like b2 to be able to run with register globals off, but that doesn't mean you have to keep them off, the important part of the .htaccess is telling Apache to parse /archives as php. _________________ -indi<br>
http://indiboi.com
http://artlikepornstars.com
http://www.positivefusion.com |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2 © 2001, 2002 phpBB Group
|