Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#136 2005-06-02 18:45:43

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Andreas > Thanks

Have you had any luck getting a date-based url (without an article title or ID) to produce a date based list of articles?

Offline

#137 2005-06-02 19:23:16

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

I use rss_suparchive for that. Have a look

For some reason, the year-only archive doesn’t work, as I’ve just noticed. Have to look into that.

Offline

#138 2005-06-08 11:37:27

chrisrhee
Member
Registered: 2004-07-01
Posts: 33
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

I just spent a bunch of time wondering why the hell this wasn’t working after I moved all the files over to a Dreamhost subdomain to do some development work. Turns out I had to disable “Run PHP as CGI” that’s highly recommended by Dreamhost. So anyone who can’t get this working on Dreamhost — try disabling that option.

Offline

#139 2005-06-12 22:30:36

nicklas
Member
Registered: 2004-04-13
Posts: 12
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Any plans of adding support for /section/id/? Because I’d like to keep my URLs short and simple.
(Well, I saw this had already been asked at the previous page but my eyes ignored it. Colour me stupid.)

Last edited by nicklas (2005-06-16 09:14:40)

Offline

#140 2005-06-16 00:40:07

sungodbiff
Archived Plugin Author
Registered: 2004-03-23
Posts: 57
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Hot damn, I’m back! Sorry about my absence, I had a lot going on and unfortunately I just didn’t have time for txp development (gasp). Anyway I’m cracking on a new version of this plugin and will keep you all posted.

For those who are curious, I’m buying my first house (or rather I’m being out-bid on several houses), I dislocated my shoulder (again) and my work-load at work tripled. The good news is, I’ve written some new URL handling code for a project at work, and it’ll be finding it’s way into the plugin shortly.

- sgb

Offline

#141 2005-06-16 11:06:23

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Welcome back, sgb!

Remember to put support for /section/category/title and error handling in ;-)

I’m looking forward to a new version of your great plugin!

Offline

#142 2005-06-17 10:21:40

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

sgb_url_handler works just by installing and activating it. The plugin looks for various sections, categories and article titles and tries to match them to an article.

Error handling is done by another plugin: sgb_error_documents which also just works by installing, activating and configuring some entries in the code view of the plugin.

Offline

#143 2005-06-17 14:33:27

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

sgb, I’ve looked briefly thru the docs for this and I’m wondering if this plugin can/could support 301 redirects? Basically what I’m looking for is a “strict” enforcement of the url structure for the site in question, rather than the default “loose” method that will serve up a document if it can find a match for your request.

For instance, such as in this example, if there is an article match for a request (but incorrect url based on my prefs) I’d like for the user to be permanently redirected to the url matching the format set in prefs.

Is this possible?

Offline

#144 2005-06-18 10:30:08

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

I’d also prefer the method Andrew proposes. It would make things cleaner while serving the same purpose as now.

Offline

#145 2005-06-18 23:28:02

sungodbiff
Archived Plugin Author
Registered: 2004-03-23
Posts: 57
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

All -

Dum da da daa! I (finally) got off my lazy butt and completed the next installment in the sordid little affair that is sgb_url_handler.

I’ve updated the download links on my site but haven’t had a chance to update the text. The help within the plugins has been updated (although I may rewrite it for the next release if things aren’t clear).

So, check the links on my site (<a href=“http://mighthitgold.net/sgb_url_handler”>sgb_url_handler</a> and <a href=“http://mighthitgold.net/sgb_error_documents”>sgb_error_documents</a>). I also updated the links on the first post of this tread.

I’ll make a second post going into more details about what’s new later this evening/tomorrow.

Enjoy!

- sgb

Last edited by sungodbiff (2005-06-18 23:29:05)

Offline

#146 2005-06-19 00:35:54

sungodbiff
Archived Plugin Author
Registered: 2004-03-23
Posts: 57
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Continuing the above post…

All configuration options are made in the function <code>sgb_url_handler_confg()</code>.

Customizable URL Schemes
This is similar to zem_rewrite, I didn’t set out to copy it, but there isn’t really a different way to do it.

Literal words can be put into schemes, e.g. /blog/&#37;section&#37;/&#37;title&#37; would match articles for URLs starting with “blog”. This is useful if you want to set up a redirect or reserve a URL for another plugin/action.

There are 6 keywords relating to TxP posts: &#37;section&#37;, &#37;category&#37;, &#37;title&#37;, &#37;year&#37;, &#37;month&#37;, and &#37;day&#37;. There are also 2 “blank” keywords, &#37;string&#37; and &#37;number&#37;. Lastly, there are 4 locale specific keywords: &#37;_section&#37;, &#37;_category&#37;, &#37;_author&#37;, and &#37;_file&#37;. For English TxP installations these would translate as section, category, author, and file_download, respectively.

It is not necessary to add a trailing slash to these schemes.

All schemes are put into the <code>$schemes</code> array in the configuration function. Schemes should be ordered in the order you wish to satisfy them. Every scheme needs to have a unique scheme name: <code>$schemes[‘scheme_name’] = ‘/&#37;section&#37;/&#37;title&#37;’;</code>. Schemes don’t automatically “flatten” so you’ll need to write a scheme for each “step” e.g. <pre>
$schemes[‘section’] = ‘/&#37;section&#37;’;
$schemes[‘section_category’] = ‘/&#37;section&#37;/&#37;category&#37;’;
$schemes[‘section_category_title’] = ‘/&#37;section&#37;/&#37;category&#37;/&#37;title&#37;’;</pre>

Per-section URL Schemes
It’s now possible to specify different URL schemes for different sections. In the configuration function just add entries to the <code>$sections</code> array e.g. <code>$sections[‘about’] = ‘section_title’;</code> would use the ‘section_title’ scheme for posts in the about section.

The permlink mode set in the TxP admin is the “default” mode, the section specified is the “preferred” mode. If the plugin is configured to send 301s it will use the scheme defined in <code>$sections</code>, if one is set.

Permlink Tag
To write permlinks with the scheme specified in <code>$sections</code> use the tag: <code>&#60;txp:sgb_url_handler_permlink&#62;</code>. This tag will use the URL scheme defined in <code>$sections</code> if there is one, otherwise it defaults to the permlink mode set in the TxP admin. This tag accepts a couple of parameters: <code>section=“some section”</code>, <code>scheme=“some_scheme”</code> and <code>mode=“some_scheme”</code>. Mode and scheme do the same thing, mode is here for compatibility with mic_permlink.

Triggers
Triggers are actions that can be executed instead of the normal TxP article response. Triggers are defined in the configuration function in the <code>$triggers</code> array.

There are a 6 triggers: RSS, ATOM, FILE, REDIRECT, AUTHOR, and NOTHING.

Currently AUTHOR and NOTHING do … nothing. They simply exit and allow sgb_url_handler to pass on the handling to TxP or whatever follows.

REDIRECT allows you to redirect URLs matching a scheme to another location, e.g. <code>$triggers[‘google’] = ‘REDIRECT::http://www.google.com’;</code> would redirect the URL http://example.com/google to http://www.google.com. Future versions will support cooler stuff like taking parts of the URL and passing them as variables in the redirection.

RSS and ATOM execute TxP’s default RSS & Atom feed responses.

FILE executes TxP’s file_download stuff.

Error Handling
To get the most out of the error handling make sure you update sgb_error_documents to version 0.1.2 or higher. sgb_url_handler now supports issuing 301 Permanently Moved headers when <code>$config[‘send_301’]</code> is set to true (it’s false by default).

sgb_url_handler will look at the scheme matched and compare it to the scheme defined for that section (or the permlink mode defined in TxP’s admin) — if the schemes are different than the user is 301-ed to the correct scheme.

If you’re running a site with send_301 enabled, you’ll want to change <code>$config[‘match’]</code> to “exact”, since you won’t really be handling “best” fits any more.

As long as <code>$config[‘send_404’]</code> is set to true, sgb_url_handler will issue 404s when an article is not found. Again, you’ll probably want to set <code>$config[‘match’]</code> to “exact”.

Well that’s the crash-course. I tested this as much as I could, but I’m sure there’ll be issues with some setups — so let me know if you have any problems.

Thanks!

- sgb

Last edited by sungodbiff (2005-06-19 00:44:59)

Offline

#147 2005-06-19 00:39:36

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

Oh baby! ;D

Offline

#148 2005-06-19 03:48:07

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

WOW. I won’t know where to begin. Thanks!

Offline

#149 2005-06-19 06:20:48

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [plugin] [ORPHAN] sgb_url_handler - support all url variations at the same time

very nice indeed

Offline

Board footer

Powered by FluxBB