![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Welcome to Deadbeef.com
SearchLinksOpen SourceOtherFavoritesWho's Online?
Misc |
|
B2Evolution: Remove dates from permalinks hack12/21/05B2Evolution: Remove dates from permalinks hackHere is a little hack to remove the dates from the permalinks, so that they will appear as http://www.example.com/index.php/posttitle instead of http://www.example.com/index.php/2005/12/12/posttitle. These instructions are for B2Evolution 1.6, since there is an existing hack for older versions. First edit the file evocore/_blog_main.inc.php
{ // We consider this a week number
$w = substr( $path_elements[$i], 1, 2 );
}
}
else
{ // We did not get a number/year...
$path_error = 404;
}
Change it to:
{ // We consider this a week number
$w = substr( $path_elements[$i], 1, 2 );
}
}
else if( isset( $path_elements[$i] ) && (!empty( $path_elements[$i] )) )
{ // We'll consider this to be a ref to a post
// We are accessing a post by permalink
// Set a lot of defaults as if we had received a complex URL:
$m = '';
$more = 1; // Display the extended entries' text
$c = 1; // Display comments
$tb = 1; // Display trackbacks
$pb = 1; // Display pingbacks
if( preg_match( "#^p([0-9]+)$#", $path_elements[$i], $req_post ) )
{ // The last param is of the form p000
// echo 'post number';
$p = $req_post[1]; // Post to display
}
else
{ // Last param is a string, we'll consider this to be a post urltitle
$title = $path_elements[$i];
// echo 'post title : ', $title;
}
}
else
{ // We did not get a number/year...
$path_error = 404;
}
If that code looks familar, it is because it was copied from the code at line 217 in that same file. That is code that is normally used after tearing off the Y/M/D. Find this code:
// This is THE CLEANEST available: RECOMMENDED!
$permalink = url_add_tail( $blogurl, mysql2date("/Y/m/d/", $post_date).$urltail );
Change it to:
// This is THE CLEANEST available: RECOMMENDED!
$permalink = url_add_tail( $blogurl, '/'.$urltail );
Comments, Pingbacks:
Comment from: Tara C. [Visitor] · http://www.dementedkitty.com
Not bad. It's quick and not too difficult to impliment after a new version release. Have is been tested on a b2evo install that hosts multiple blogs across multiple domains?
Comment from: Jeremy [Member]
I have two blogs here in separate folders. One at http://www.deadbeef.com and http://www.deadbeef.com/jeremy and things work. I have not tested this where the blogs are on different domains.
Comment from: personman [Visitor]
Works great for me. I'm using 1.8-cvs. Thanks!
Comment from: Danny Ferguson [Visitor]
I have this working with 1.8, beta. The only thing that changed is the file locations:
/inc/_blog_main.inc.php /inc/MODEL/items/_item.class.php
Comment from: Finkregh [Visitor]
is it somehow possibe to add a 503 (site moved) so already existing permalinks in the "old" date-style?
Comment from: Jeremy [Member]
The old date-style permalinks will still work just fine. I suppose you could go in and put in redirects, but I didn't bother, since I implemented this change before any of my permalinks were released into the wild.
Comment from: Anne [Visitor]
Do you use this in 1.8.2 ?
Because for the naked eye, it does what it is suppose to do, but there are a few downsides. Very odd, but registering new users is down... Is this only my installations (5) or do you have that problem to ?
Comment from: CMB [Visitor]
This still works as of version 1.9.2, with a couple of minor differences:
The first file to be changed is now: /inc/_blog_main.inc.php This should be altered as described in the main post. The second is file is now: /inc/MODEL/items/_item.functs.php The function that needs editing is get_permalink (for some reason the archives plugin currently uses the deprecated get_permalink rather than its replaced version get_permanent_url). I have never done any php before so I reckon this hack is probably a real mess, but it works :) Find the bit of code that the main post tells you to change, and alter it to: //This is THE CLEANEST available: RECOMMENDED!
Comment from: Mark DeNio [Visitor]
I'm using 1.9.3 and had to make two modifications:
The main post modification for /inc/_blog_main.inc.php is still correct. I changed /inc/MODEL/items/_item.funcs.php to:
I also wound up changing the archives plugin file /plugins/_archives.plugin.php (around line 243). Here's the original code:
I changed the 'id' parameter to 'title'.
I don't have my site converted to b2e yet. Just learning on a local install first. Leave a comment:
|
|
Sponsored LinksTop Articles
Categories
Archives
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||