Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-18 00:10:07

Aleksandersen
Member
From: Lillehammer, Norway
Registered: 2007-04-12
Posts: 77

Customize feed URLs

Hi,

I want to customize my feed URLs. How can I get these URLs (Atom formatted) without doing an additional Apache rewrite rule on top on Textpattern’s rewrite rules?

http://mysite.net/kanal/
http://mysite.net/kanal/sectionname/

Offline

#2 2007-05-18 01:38:55

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

Re: Customize feed URLs

Modify a Textpattern file (textpattern/publish.php).

Offline

#3 2007-05-18 01:47:55

Aleksandersen
Member
From: Lillehammer, Norway
Registered: 2007-04-12
Posts: 77

Re: Customize feed URLs

Thanks, Mary! :)

I figured out how to do /kanal/, but I have not been able to figure out how to do /kanal/sectionname/. Do you happen to know where what I should look at to get that working?

Offline

#4 2007-05-18 02:05:01

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

Re: Customize feed URLs

It just occured to me that there may be a plugin that lets you do this kind of stuff with URLs, so you might want to look into that (plugin is better than hacking).

I imagine you got it working within the following section of code:

switch($u1) {

	case 'atom':
		include txpath.'/publish/atom.php'; exit(atom());

	case 'rss':
		include txpath.'/publish/rss.php'; exit(rss());

If so, $u2 would have in it the section name. Both the Atom and RSS feeds look for the section name in $_GET['section'], so all you should need to do is add the following to each case, but before each include statement:

$_GET['section'] = $u2;

That’s all you need to do, since the feeds do the necessary after that. Looks something like:

switch($u1) {

	case 'atom':
		$_GET['section'] = $u2;
		include txpath.'/publish/atom.php'; exit(atom());

	case 'rss':
		$_GET['section'] = $u2;
		include txpath.'/publish/rss.php'; exit(rss());

Offline

#5 2007-05-18 02:28:07

Aleksandersen
Member
From: Lillehammer, Norway
Registered: 2007-04-12
Posts: 77

Re: Customize feed URLs

Mary wrote:

It just occured to me that there may be a plugin that lets you do this kind of stuff with URLs, so you might want to look into that (plugin is better than hacking).

Yea, there were many. But all outdated.

I imagine you got it working within the following section of code: (..)

I added a case kilder, and that is how I got that part working. However I could not make heads or tails of rewriting the sections.

Offline

#6 2007-05-19 18:25:29

Aleksandersen
Member
From: Lillehammer, Norway
Registered: 2007-04-12
Posts: 77

Re: Customize feed URLs

OK, I cannot get it to work properly. I think I will have to go for localised URLs in stead. How can I localise the URLs by replasing “section=” by “seksjon=”?

Offline

#7 2007-05-20 01:21:41

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

Re: Customize feed URLs

That would actually require more changes. Try this:

switch($u1) {

	case 'kanal':
		$_GET['section'] = $u2;
		include txpath.'/publish/atom.php'; exit(atom());

	case 'rss':

Offline

Board footer

Powered by FluxBB