Archived : Techno Babble

This is the archived version of my b2evolution code blog.
If you require any help regarding b2evolution then
visit it's support forums

You can find my current blogs here
Code : {@link : WafflesOn}
Personal : {@link : InnerVisions}

« Search Highlight part deuxXSS should you care? »

Relative links with B2evolution

Posted on 21st Jan 2007 in : Plugins & Widgets

I don't know about you lot, but one of the things that I dislike about b2evolution is the fact that you have to use absolute urls in your posts. This is great if your blog always remains on the same (sub)domain, but if you ever want to move it then you're screwed! Up until now your only recourse was to either hit the database and change all of the affected urls in your posts or to manually edit each of your affected posts in admin. Not exactly user-friendly and it pretty much goes against the grain of how a website should be coded in the real world.

I've always coded my websites with relative links as it makes them truly "portable" and it's a habbit that I've continued with my blogs by hacking the bbcode plugin to allow me to use http://site/ to point to my blogs $baseurl ..... which worked right up to the moment when I merged two of my blogs that reside on two totally seperate domain names ( InnerVisions and WafflesOn ). Rather than piss about with the bbcode plugin (and have to reapply the hacks on every upgrade) I created a shiny new plugin to cope with my current needs. Basically this plugin adds 3 "special urls" that I can use for my posts to keep my links as relative as possible

http://site/
This gets converted into the posts blog url, so I can now make links relative to the individual blogs folder
http://base/
This gets converted into the $baseurl, so now I can make links relative to my install folder, which in my case is the same folder, but on a less trick install these could be different.
http://media/
Spookily enough, this gets converted into $media_url, just to make it a smidge simpler for me to move my media folder if ever the occasion arises.

Hopefully a certain unamed yank will get the time before the next ice-age to do a full write-up on AstonishMe, but if you want to have a play with this plugin in the meantime then you can find it here. You can't help but notice that I've dumped it in my media folder in a demonstative kind of way ;)

Have fun
¥

*edit*

Cured a minor bug in admin, zip file updated 31st Jan

1 comment

Comment by Walter Cruz { @link http://devlog.waltercruz.com } on 10/03/09
Oh man! I will gonna love that!
Page archived : 11th Nov 2009
 

X