Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-01-28 05:46:28

kimili
Plugin Author
From: Massachusetts, USA
Registered: 2004-06-17
Posts: 108
Website

How do I determine whether a user is accessing a feed?

I’m trying to work out how to determine whether or not a user has requested an RSS or ATOM feed from within a plugin. I thought that checking gps('rss') and gps('atom') would do the trick, but I seem to be missing something. I have code that looks something like this:

if (gps('rss') || gps('atom')) {                  
	Process content appropriately for a feed...
} else {                                         
	...otherwise process content normally. 
} 

But it always defaults to the else condition. Can anybody shed a little light on how I can work this out reliably?

Thanks,
Michael

Offline

#2 2007-01-29 02:22:14

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: How do I determine whether a user is accessing a feed?

Michael

I think you need to do it as part of a ‘pretext’ callback.

Last edited by net-carver (2007-01-29 02:22:58)


Steve

Offline

#3 2007-01-30 20:27:25

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

Re: How do I determine whether a user is accessing a feed?

Yep, Steve is correct.

Offline

#4 2007-01-30 22:24:39

kimili
Plugin Author
From: Massachusetts, USA
Registered: 2004-06-17
Posts: 108
Website

Re: How do I determine whether a user is accessing a feed?

Steve & Mary

Thanks for the guidance – now I’m halfway there. It looks like I can pick up gps('rss') and gps('atom') in a pretext callback, but only when using messy URLs.

I’ll do some more digging to see if I can work it out, but if you have any ideas, I’d be happy to hear them.

Thanks,
Michael

Offline

#5 2007-01-30 23:02:38

kimili
Plugin Author
From: Massachusetts, USA
Registered: 2004-06-17
Posts: 108
Website

Re: How do I determine whether a user is accessing a feed?

Actually, I think I’ve sussed it out by poring through publish.php. I’ve got the following code which is doing the trick:

	global $permlink_mode;

if ($permlink_mode "messy") { $state = (gps('rss') || gps('atom')) ? "feed" : "site"; } else { $req = serverSet('REQUEST_URI'); extract(chopUrl($req)); $state = ($u1 ‘rss’ || $u1 == ‘atom’) ? “feed” : “site”; }

That seems reasonable to me. Do you forsee any issues with it?

Thanks again,
Michael

Offline

#6 2007-01-30 23:40:42

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

Re: How do I determine whether a user is accessing a feed?

Do you forsee any issues with it?

Nope, that should work okay. :)

Offline

#7 2007-01-31 01:57:38

kimili
Plugin Author
From: Massachusetts, USA
Registered: 2004-06-17
Posts: 108
Website

Re: How do I determine whether a user is accessing a feed?

Excellent! Thanks Mary.

Offline

Board footer

Powered by FluxBB