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
Wilshire -
Thanks for the kind words!
Zero -
I’m working on a companion plugin “sgb_error_documents” to add this feature to TxP. I should have the kinks worked out and posted this weekend. An update to sgb_url_handler will automatically use sgb_error_documents if it is available. The errors will be customizable and will be triggered if an article, section, category are not found.
- sgb
Last edited by sungodbiff (2005-03-09 15:34:18)
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
What exactly the plugin does? Does it redirect (301) from all URL variants to the preferred one, or simply display the same duplicate content on many different URLs?
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Marek -
It does not issue a redirect. It allows content to be accessible through any of the supported URLs.
- sgb
Offline
#19 2005-03-11 02:10:03
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
“I’m working on a companion plugin ‘sgb_error_documents’ to add this feature to TxP.”
Oh good! I discovered the same thing as zero: if I visit a “sub-page” that isn’t there, it shows that section’s default page. I’m looking forward to this addition.
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
This plugin is just great. I had reached the same effect by hacking into publish.php, but your plugin is much better. I too look forward your error documents plugin.
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Mary, I actually like the way it redirects to site/section/ when I typed in site/section/wrongaddress. However, I don’t like it if I type site/wrongaddress and it redirects me to site/. That’s when I want a custom 404.
Great plugin, those clean urls make design a lot easier!
Dozy P My attempt at music
Offline
#22 2005-03-11 23:16:17
- nardo
- Member

- From: tuvalahiti
- Registered: 2004-04-22
- Posts: 743
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
bloody marvellous!
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
I have a bug and fix: if I have two articles with the same title in different sections and write a /Section/Title URL, the plugin can match the wrong URL, as it uses the lookupByTitle() function, wich doesn’t takes sections into account.
My fix is to add this function to the plugin:
function lookupBySectionTitle($where,$title,$debug=’‘)
{
return safe_row(“ID,Section”,“textpattern”,
“section like ‘”.doSlash($where).”%’ and url_title like ‘“.doSlash($title).”’ limit 1”);
}
and then use it to lookup /Section/Title style URLs.
Will have to check if this is a problem for TXP too…
Offline
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
micampe -
Damn. You ruined my surprise! :)
I also noticed at also when I was initially developing this plugin. It was on my todo list for version 0.1.4. Which I should hopefully have posted some time today. This version will also support basic 404 functionality through my sgb_error_documents plugin (which will be released when I update this one).
0.1.4 will use sections whenever available to assist in locating the correct article. It won’t do much good for /Title URLs.
Good eye though!
- sgb
Last edited by sungodbiff (2005-03-13 17:29:01)
Offline
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
Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time
Alrighty, almighty Sun God Biff!
Works a treat! This is truly excellent! Thank you very much!
Dozy P My attempt at music
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.
Dozy P My attempt at music
Offline