dev.michaelgravel.com

textpattern ~ code ~ css

Jul 20 2007

Plugin: mg_setheader

The plugin <txp:mg_setheader /> allows one to change/specify the header for any textpattern page. By default, textpattern delivers section pages as text/html. This plugin can be used to serve up a valid RSS feed from a standard page template.

Download it: <txp:mg_setheader />

Attributes

This plugin takes two attributes:

  • name: Defaults to ‘Content-Type’
  • value: Defaults to ‘text/xml’

Examples

Example #1:

<txp:mg_setheader name="Content-Type" value="application/rss+xml" /><?xml version="1.0" encoding="UTF-8"?> 
(and so on...) 

The above example would be used on a page template and would set the header for that page to the spec’d value. In the above example, you could generate a valid RSS feed using the appropriate RSS tags (see the RSS spec for more information) and standard textpattern tags. This would allow you to insert images, create podcasts (see my tutorial Podcasting With Textpattern), and place images at the top of your feeds.

Example #2:

<txp:mg_setheader /><?xml version="1.0" encoding="UTF-8"?> 
(and so on...) 

The above example simply sets the header to ‘text/xml’ (which is an equally valid header for an RSS feed).

Notes on usage

This plugin is most commonly used to generate an RSS feed from a standard Textpattern page template. When you do this, <txp:mg_setheader /> must reside AT THE VERY TOP OF YOUR PAGE TEMPLATE, and the opening <?xml> tag must follow IMMEDIATELY behind it (i.e. no linebreak, no space between the <txp:mg_setheader /> tag and the opening <?xml> tag).

Credits

I’d love to take credit for this, but the code belongs to Sencer. I gleaned this from a post in the textpattern forum. I can’t seem to find the thread, otherwise I’d post a link here.

Posted in text on July 20, 2007

3 comments added

Congrats; really useful plugin. Do you have an any idea how can we use with xhtml-mp header? Because it seems like we’ve got a way for mobil devices page publications.

prolog    Jul 29, 2007 15:26

Prolog: Not sure. I’m not too familiar with the xhtml-mp header and what it can do. Sounds intriguing, though.

Mike    Jul 30, 2007 08:36

Mike: xhtml-mp header means of mobil devices docytpe; I trided to add application:vnd:wap-xml-xhtml my page template header and it works. You can see it action in here:http://www.edirnevdb.gov.tr/mobil-bilgi (sorry-this is small goverment site for turkish)

That web pages works with all series40 and 60 color screen Nokia and other OpenWave support phones, PDA’s; I tested with simulators,only must be careful about size:mobil page size limit 10kb for old devices.

Now I can do webpages for mobil devices with textpattern, very easily…This is just simple sample.

If you wish to see whats going on drop me mail and I send you my txp page and form templates..

Thanx for all amazing works; my best wishes, regardly…

prolog    Aug 10, 2007 00:05

Commenting disabled.

Text

Welcome to the Text archives. This is where I write about Textpattern, a lightweight, PHP-based content management system.

side image

Textpattern Plugins

I've made a few plugins for Textpattern that provide very modest additions to the software's existing functionality. Here they are: