Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-03-05 22:58:27

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

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

Current Release

Previous Release: <a href=“http://mighthitgold.net/swap/sgb_url_handler-0.1.5.txt”>Download sgb_url_handler (0.1.5)</a> | <a href=“http://mighthitgold.net/swap/sgb_error_documents-0.1.1.txt”>Download sgb_error_documents (0.1.1)</a>

Update 2005-06-20: <a href=“http://forum.textpattern.com/viewtopic.php?pid=60678#p60678”>Please read this post</a>.

I’ve posted elsewhere about making modifications to TxP in order to support all URL formats at the same time. Rather than make the modifications directly to TxP I rolled them into a plugin.

This is my first TxP plugin so let me know if there is some protocol I should follow :)

You can grab the plugin <a href=“http://mighthitgold.net/swap/sgb_url_handler-0.1.5.txt”>here</a>. Just copy and paste into your “Install Plugin” field in your TxP Admin. This plugin was designed and tested with TxP 1.0 RC3 (updated from subversion on 2005-03-05).

Now for some background. I love the fact Dean & Co. add so many URL options to TxP. However only supporting one type of incoming link at a time seems like an oversight to me. While links on your own site might not break when you change modes, links off-site (such as links posted in forums or wikis) will. This plugin allows you to change your URL mode at will while still supporting any/all URL formats.

Currently it supports the following formats:
example.com/section/id/title
example.com/section/title
example.com/section/category/title
example.com/section/category
example.com/section
example.com/title
example.com/id/title
example.com/year/month/day/title (although this appears to be broken in RC3)

Additionally, this plugin supports the following trigger words:
example.com/{section}/Section
example.com/{category}/Category
example.com/{author}/Author
example.com/atom
example.com/rss

The plugin supports all these modes with or without a trailing slash. In the event of collisions, the plugin will check the more general term first, e.g. /Section will be checked before /Title.

Also note that this plugin is designed to work with clean URLs on servers without mod_rewrite. You’ll need to modify your links and append index.php/ to the beginning, e.g. example.com/index.php/section/id/title is the same as example.com/section/id/title.

The plugin “pipes” /Section, /Category and /Author requests to the corresponding $_GET, $_POST super globals so they are handled normally by TxP.

If the plugin can’t figure something out it just returns and let’s TxP handle it normally.

I’ve written instructions for adding permlink modes for /Section/Title and /Section/Category/Title. These instructions can be found <a href=“http://mighthitgold.net/swap/txt_url_modifications_2005-03-07.txt”>here</a>.

Thanks to Dean & Co for their work on TxP!

- sgb

Edit: Updated instructions for adding new permlink modes.

Last edited by sungodbiff (2005-07-01 14:14:11)

Offline

#2 2005-03-05 23:00:37

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

Just to reiterate, make sure you’re using the most recent version of RC 3. I know early versions weren’t saving URL-friendly versions of titles (which is essentially to several of the URL modes).

- sgb

Offline

#3 2005-03-06 21:31:48

cnolle
Archived Plugin Author
Registered: 2004-03-21
Posts: 87
Website

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

This works wonderfully. Thanks for the good work.

Offline

#4 2005-03-06 22:48:55

qrayg
Member
From: USA
Registered: 2004-08-27
Posts: 81
Website

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

Awesome… works perfectly now. Thank you sooooooo much.

Offline

#5 2005-03-07 03:12:31

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

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

Ooo. This might solve part of the quandry I’ve been having…

Offline

#6 2005-03-07 15:38:57

PeterS
Member
From: Cleveland, Ohio
Registered: 2004-03-06
Posts: 38
Website

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

Worked like magic, SGB. This is something that definately should be included in TXP by default. Thank you, thank you, thank you.


The following is true
The above statement is false.

Offline

#7 2005-03-07 22:09:35

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,443
Website

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

“Also note that this plugin is designed to work with clean URLs on servers without mod_rewrite. You’ll need to modify your links and append index.php/ to the beginning, e.g. example.com/index.php/section/id/title is the same as example.com/section/id/title.”

Hi, I installed it and it all seemed fine but then I couldn’t open mysite.com nor mysite.com/?c=intro and everything stalled for a couple of minutes before I got the message No such section default or something like that. Is this because of the above paragraph. I don’t understand what mod rewrite is. I am on TextDrive, so do I have to change something?


Gud One Blog
Wondrous Healing Wondrous ways to a healthy old age

Offline

#8 2005-03-07 22:13:14

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,443
Website

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

Mmm… I am having a strange time tonight. I just tried again and mysite.com and mysite/?c=intro worked just fine. However, my question still remains about the mod rewrite and if I have to change anything. Thanks


Gud One Blog
Wondrous Healing Wondrous ways to a healthy old age

Offline

#9 2005-03-07 22:58:27

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

Zero -

Are you on Textdrive? I’ve had a weird time with the database being unavailable off and on (resulting in the “No such section” message).

Mod_rewrite is an Apache module that manipulates URLs strings, allowing you to redirect URLs to other places. Clean URLs in TxP RC3 rely on mod_rewrite to function. Some servers may not have it available (rare but not uncommon), fortunately PHP has a great feature where you can “pipe” URLs through a script.

My plugin takes advantage of that. So long story short, if you’re on a server without mod_rewrite you can still enjoy clean URLs by appending index.php in front on all your links, e.g.

example.com/section/category/title becomes example.com/index.php/section/category/title.

My plugin doesn’t offer any tags to create links. Maybe I’ll add it some day, but the goal of this plugin was just to “handle” URLs not create them.

Hope this answers your questions. If you’re still getting weird messages let me know and we’ll figure it out.

- sgb

Offline

#10 2005-03-08 02:58:38

gustaf
Member
From: Santa Cruz, California
Registered: 2004-12-29
Posts: 17
Website

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

is it possible to deactivate specific combinations (e.g. in the event that categories and articles have the same name, thus proving confusing)?

Offline

#11 2005-03-08 03:22:46

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

It is possible but the plugin was designed to “just work” so there isn’t a simple way to deactivate certain sections.

The plugin is designed to favor more general terms first, for example let’s say I had an article titled “this-site” in the “this-site” category of the “about” section: /about/this-site/this-site would point to the article, but /about/this-site would point to the category (regardless of permlink mode).

I figured this made the most sense for handling collisions as it kept the heirarchy intact.

I’ll look into adding an option to disable, perhaps there is an elegant way to do this, let me know if it is a must-have.

Thanks

- sgb

Offline

#12 2005-03-08 05:36:20

gustaf
Member
From: Santa Cruz, California
Registered: 2004-12-29
Posts: 17
Website

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

the problem is i have a whole heck of alot of articles with the same names as the categories they are present in (its how i manage a certain dynamic aspect). for instance, when you navigate to the “about” section, it lists the few articles, with links to “about/{article title}”. but when “about/{article title}” is requested, it returns the article category instead. even though there is only one article in the category, it still lists it (as opposed to the full article). and even when you click on the article link from there, it redirects you to the same page.

you can see what i’m talking about here

is there a line of code i could edit? i’m sure creating the option to disable would probably require alot of work on your part, and my case is probably an isolated one.

‘preciate it,
-gustaf

Last edited by gustaf (2005-03-08 05:37:15)

Offline

Board footer

Powered by FluxBB