Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Alrighty. sgb_url_handler 0.1.4 is out (see the download link on the first post). I also want to annouce sgb_error_documents 0.1.1 (see download link on the first post). You’ll need both installed and activated if you want to have 404 Not Found support.
New features for sgb_url_handlers:
Added more robust support for determining the correct article. This was something I wanted to add in 0.1.4 and it was also suggested by micampe. Whenever both a section and a title are specified the plugin will use sgb_lookupBySectionTitle to determine the ID (I wanted to avoid a collision with TxP in the event a similar function is added).
I also added 404 Not Found support per Zero’s & Mary’s request. This is implemented through the companion plugin sgb_error_documents. If sgb_error_documents is installed and active sgb_url_handler will trigger 404s for the following situations:
example.com/validSection/Category/InvalidTitle
example.com/InvalidSection/Category/ValidTitle
example.com/validSection/InvalidTitle
example.com/InvalidSection/ValidTitle
example.com/AnySection/InvalidID/AnyTitle
example.com/AnySection/InvalidCategory
I added this as a separate plugin so that it could be used more freely, I also wanted to support more than 404s (although at the moment all it supports is 403 and 404s).
Announcing sgb_error_documents:
sgb_error_documents adds error document handling to TxP. Currently the plugin supports two error codes, 403 Forbidden and 404 Not Found, more can easily be add. (Although this plugin was designed as a companion to sgb_url_handler it can be used by any plugin/hack.)
The plugin responds to each error code in one of four possible ways; by displaying an article on your site (ID), redirecting to an error page (URL), including an error document (file) or by simply outputting error text (text). The plugin responds to an error in the order specified above (ID, URL, file and text). If the ID is not set or is not found, the plugin will try the URL. If the URL is not set the plugin will try the file. If the file is not found, the plugin will output the text, defaulting to standard message if custom text is not set.
If an error code is passed to the plugin that is not under stood, the plugin will not do anything.
id:
The id should be of an article available in your article database. You may wish set up a dedicated “Errors” section to prevent the errors articles from being listed with your normal posts.
url:
The URL should be an absolute URL to a page explaining the specified error code. If this error is triggered users will be redirected to this page.
file:
The file element should be a relative path (to index.php) to a file explaining a particular error code. The function will exit() immediately following the inclusion of the file (terminating any further TxP actions).
text:
This text will be echoed to the browser, if it is not specified a default message will be displayed. This text can contained HTML code. The plugin will issue an exit() call immediately after echoing the text (terminating any further TxP actions).
After installing sgb_error_documents, click edit to change the configuration, all configuration options are listed in the first function.
I hope this helps!
- sgb
Last edited by sungodbiff (2005-03-14 00:36:37)
Offline
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Here’s me again, again with bugs :)
If I enable the error_document plugin, my CSS gives 404. You probably should filter out /textpattern/ as a fake section in the url plugin.
You don’t see the problem because you’re using an external static stylesheet.
Oh, and lovely website you have, I really like the graphic layout.
Last edited by micampe (2005-03-14 12:10:58)
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Micampe -
Good catch! Actually sgb_url_handlers is causing the problem. I’ve got a fix and I’ll post it later this morning, once I get into work.
The short answer would be to comment out the sgb_error_document() call at the end of the sgb_url_checkPath() function in sgb_url_handler. There is a bit more to it than that (since that disables a couple situations where we’d want a 404).
Looks like I’ll be releasing a 0.1.5 early :)
- sgb
Last edited by sungodbiff (2005-03-14 13:10:46)
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Okay. sgb_url_handler 0.1.5 is posted (see the first post for the download link).
Hopefully this fix will prevent any further incorrect 404s.
Thanks micampe!
Edit: I also added support for file_downloads to the plugin.
- sgb
Last edited by sungodbiff (2005-03-14 18:46:22)
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Hi Sun God Biff! There’s possibly a problem with mysite.com/index.php. I was getting 404s for it, so I changed those addresses to mysite.com/ and all was OK. Then I found you had a new version. I’ve updated and mysite.com/index.php now seems OK again. I’ll let you know if it happens again.
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Zero –
Let me know if you still have problems, but the recent (0.1.5) release should fix it.
Edit: It’s a Monday, make sure you re-download 0.1.5 even if you grabbed it earlier today. There was a bone-headed mistake. Sorry!
- sgb
Last edited by sungodbiff (2005-03-14 22:08:08)
Offline
#32 2005-03-15 16:14:14
- rob_roy
- Archived Plugin Author
- Registered: 2005-02-28
- Posts: 18
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
SGB,
Is there a reason the sgb_error_documents doesn’t (or can’t) send the appropriate header for cases of url redirect? If I use ID, the error document ends up going to my default template, so I get things like article navigation and other gubbins I’ve stuck on the default template. I much prefer the scenaria of redirecting to \error\$code since I have better control over the page layout. In that case, however, I prefer to make sure the client knows it’s gotten an error, as well as the person reading the client, y’know?
Can it be as simple as adding <code>header($headers[$code]);</code> to the redirect section?
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
rob_roy -
Glad you asked. To be honest I wasn’t sure what was proper in that situation (does any one know?). I didn’t want to mess up the redirect by sending a different status code, plus I figured users could always have the error page send the status code. That way the browser would get the correct error while actually seeing the corresponding error message.
It’s pretty simple to change (as you already noted in your post) though and I can certainly modify it to send the error code before the redirect. Alternatively you could also use the file property and get the same effect with out having to redirect.
Hope this helps!
- sgb
Last edited by sungodbiff (2005-03-15 16:46:19)
Offline
#34 2005-03-18 05:20:16
- Anark
- Member
- Registered: 2004-08-14
- Posts: 101
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Not to rain on anyone’s parade, but this plugin makes me uneasy: “mirrors” and suchlike aside, the internet has so far been doing quite well using the principle that one URL corresponds to one document and vice versa. You’re effectively saying that this principle should no longer apply, and that any document, at the webmaster’s whim, should have eight (sixteen, thirty-two, where to stop?) different URLs. True, this may relieve the webmaster of the necessity to plan ahead, pick an URL scheme and then jolly well stick to it, but look at it from the user’s perspective and you’ll realise you’ve got a usability issue on your hands.
To pick an obvious example, think of Google trying to calculate the pagerank of any one of your documents: let’s say your document has 200 inpointing links. These inpointing links, however, reference all eight URLs of that document. For Google to weigh these links adequately, it will first have to find out that it’s dealing with one document rather than eight.
It’ll take a while until the folks at Google will respond to the reality that documents on the Internet now have any number of different URLs. They will grumble a bit about it, but then they will begin to compare pages and come up with whatever computation is necessary to stop these eight URLs counting as eight documents.
Until that happens, search users will have to deal with the annoyance of the same document showing up as eight different documents.
This is just off the top of my head — I’m sure you could think up quite a number of negative effects that multiple URLs have.
Call me old-fashioned but as a Web user I like the idea that in most cases one document will correspond to one URL, and that a placeholder or a server-side redirect should point to a new URL if the old one changes (which, in an ideal world, it wouldn’t anyway). You propose to get around this and go easier on the webmaster, but you end up making things harder for everyone else.
I found this thread because I was looking for a way to create a /section/title URL scheme. Sungodbiff — I’d feel a lot better about the plugin if it allowed me to do that and just that.
Last edited by Anark (2005-03-18 07:26:53)
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Anark – Agreed with pretty much everything you’ve said. The only thing I’m using now is the ability to have section/title URLs but could also see myself using section/category/title at some point on another site.
I think if you design a site using that URL scheme and stick to it, you won’t run into any problems. Whether you’re using this plugin or not, changing your linking scheme will cause problems for search engines anyway. Its definitely not to change your linking scheme weekly just for fun.
Unfortunately, the bad thing about google pagerank is that when people link to you, the chances that they all use the same anchor text an link are slim anyway.
Points very well taken though.
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
I understand the points above and while I don’t agree 100%, I am addressing the issue. I’m currently in the process of testing sgb_url_handler 0.1.6 and sgb_error_documents 0.1.2.
sgb_error_documents 0.1.2 will add support for 301 Move Permanently and sgb_url_handler 0.1.6 will issue 301s if the parsed URL does not match the currently set URL mode (for articles only; section, category, author, feed and file urls will still be handled normally).
This means if your TxP install is set to serve /section/title and someone accesses an article using /section/id/title they will be redirected to the correct /section/title URL (a 301 will be sent prior to the redirect).
Search engines and savvy browsers can do their update thing and the plugin can fulfill it’s original goal of keeping content available.
I’ve got an alpha build working on my site now, but I need to test it some more before I release it. I’ll probably release them this weekend (tomorrow).
- sgb
Edit: Made some clarifications, just in case there was any confusion.
Last edited by sungodbiff (2005-03-18 17:24:11)
Offline