Horrell.ca

You are currently viewing all articles in the category “Textpattern”.

In which I present my 3rd and 4th Textpattern Plugins

Posted 1124 days ago in Archive, modified 1118 days ago

Introducing my third and fourth Textpattern plugins:

They’re pretty much a matched set and compliment cwh_link_to_home in functionality. These ones took a little longer to produce than cwh_link_to_home, partly because I was stumped for a bit as to how to maintain the functionality of the tags they replace, but also due to a healthy bought of procrastination. Fantastic method to problem solving that, especially when there’s no deadline looming.

cwh_link_to_prev

Posted 1124 days ago in Code, modified 364 days ago

cwh_link_to_prev is a Textpattern plugin that provides a replacement tag for <txp:link_to_prev /> that includes a new format attribute which provides the ability to set the link format as a link tag suitable for placing in the head of any individual article page on your site. You can do this by setting the format attribute like so:

<txp:cwh_link_to_prev title="Previous" format="link" />

which will produce something similar to:

<link rel="prev" href="http://example.com/article/1/previous-post" title="Previous Post" />

Note that when used as a single tag without the format attribute specified:

<txp:cwh_link_to_prev />

it will produce a plain text link much in the same way as <txp:link_to_prev />:

http://example.com/article/1/previous-post

Finally, it can also be used as a container tag in the same manner as <txp:link_to_prev /> if no format value is specified:

<txp:cwh_link_to_prev> ...Text or Tag... </txp:cwh_link_to_prev>

If you do specify a link value for the format attribute while used as a container tag, it will still produce a link tag.

This tag also shares all of the same attributes as <txp:link_to_prev />. For a complete list of applicable attributes, see this Textbook entry.

For a further explanation of the benefits of using link tags for your site’s navigation, please see Day 9: Providing additional navigation aids from Mark Pilgrim’s Dive Into Accessibility.

Download: cwh_link_to_prev.txt ~5KB

Created: 12/08/2007 10:49 PM

Modified: 10/09/2009 04:03 PM

Total downloads: 781

(see also cwh_link_to_next and cwh_link_to_home)

cwh_link_to_next

Posted 1124 days ago in Code, modified 364 days ago

cwh_link_to_next is a Textpattern plugin that provides a replacement tag for <txp:link_to_next /> that includes a new format attribute which provides the ability to set the link format as a link tag suitable for placing in the head of any individual article page on your site. You can do this by setting the format attribute like so:

<txp:cwh_link_to_next title="Next" format="link" />

which will produce something similar to:

<link rel="next" href="http://example.com/article/2/next-post" title="Next Post" />

Note that when used as a single tag without the format attribute specified:

<txp:cwh_link_to_next />

if will produce a plain text link much in the same way as <txp:link_to_next />:

http://example.com/article/2/next-post

Finally, it can also be used as a container tag in the same manner as <txp:link_to_next /> if no format value is specified:

<txp:cwh_link_to_next> ...Text or Tag... </txp:cwh_link_to_next>

If you do specify a link value for the format attribute while used as a container tag, it will still produce a link tag.

This tag also shares all of the same attributes as <txp:link_to_next />. For a complete list of applicable attributes, see this Textbook entry.

For a further explanation of the benefits of using link tags for your site’s navigation, please see Day 9: Providing additional navigation aids from Mark Pilgrim’s Dive Into Accessibility.

Download: cwh_link_to_next.txt ~5KB

Created: 12/08/2007 10:48 PM

Modified: 10/09/2009 04:03 PM

Total downloads: 773

(see also cwh_link_to_prev and cwh_link_to_home)

cwh_link_to_home

Posted 1207 days ago in Code, modified 1113 days ago

cwh_link_to_home is a Textpattern plugin that provides replacement tag for <txp:link_to_home /> that includes a new format attribute which provides the ability to set the link format as a <link> tag suitable for placing in the <head> of any page on your site. You can do this by setting the attribute format to link, like so:

<txp:cwh_link_to_home title="Home" format="link" />

which will produce something similar to:

<link rel="home" title="Home" href="http://yourdomain.tld/" />

This tag also shares all of the same attributes as <txp:link_to_home />. For a complete list of applicable attributes, see this Textbook entry.

For a further explanation of the benefits of using <link> tags for your site’s navigation, please see Day 9: Providing additional navigation aids from Mark Pilgrim’s Dive Into Accessibility.

Download: cwh_link_to_home.txt ~4KB

Created: 21/05/2007 04:39 PM

Modified: 26/08/2007 01:35 AM

Total downloads: 867

(see also cwh_link_to_prev and cwh_link_to_next)

cwh_hobo

Posted 1256 days ago in Code, modified 524 days ago

cwh_hobo is a Textpattern plugin that will display a random hobo name from John Hodgeman’s list of 700 hobo names taken from his book The Areas of my Expertise (more information here). Once installed, you use it by simply placing the follwing in any article, page, or form within Textpattern:

<txp:cwh_hobo />

This will produce a random hobo name, and number, like so:

#171: Twink the Reading-Room Snoozer

cwh_hobo also accepts two attributes: wraptag and class. So, for instance, if you want to wrap the output in a paragraph tag with the class of “hobo”, you’d have the following:

<txp:cwh_hobo wraptag="p" class="hobo" />

which would produce:

<p class="hobo">#171: Twink the Reading-Room Snoozer</p>

Pretty neat, eh? You can download this plugin below.

Download: cwh_hobo-0.2.txt ~37KB

Created: 27/04/2007 02:19 AM

Modified: 13/07/2007 01:11 PM

Total downloads: 1038

cwh_hobo Update

Posted 1257 days ago in Archive, modified 1257 days ago

I did a thorough review of all the hobo names in cwh_hobo and I discovered that there were quite a few typos in the original plugin. That and there were a lot of unencoded entities as well, so that’s fixed now as of version 0.2. You can download the latest version from the cwh_hobo page.

If you think crosschecking 700 hobo names against the original text is a laborious task, you would be right. I regret nothing.

In which I present my first Textpattern Plugin

Posted 1286 days ago in Archive, modified 1221 days ago

I’ve been teaching myself a bit of PHP and, as I’ve learned from past experience, the best way to go about this sort of thing is through practical application. What you need to do is to actually create something useful, something that you’ll actually use in your day-to-day life. Or, failing that, it should be something that amuses or interests you.

And so, with that in mind, I set about creating a Textpatten plugin with one purpose and one purpose only: To generate a random hobo name taken from the list of 700 such names from John Hodgeman’s The Areas of my Expertise.

I therefore present to you cwh_hobo and you can see it in action in the sidebar. You’ll also note that my site now sports a new Code section where I’ll hopefully be adding other plugins and contrivances in the future.

Oh, and do let me know if you catch any errors or issues with cwh_hobo and I’ll be sure to correct them as soon as I can. You can do so by contacting me directly.

Enjoy!

Introducing the Mobile version!

Posted 1335 days ago in Archive, modified 1331 days ago

A few months ago I purchased horrel.mobi with the vague inclination of actually doing something with it like, you know, a mobile version of this site. I struggled a bit with how to do this since I was having a hard time trying to figure out how to serve a different page to the new domain from Textpattern. Then, along came the ied_if_domain plugin (original forum post) and my problem was solved. Interestingly, I also figured out another handy solution using SimplePie, but I’ll get to both of those solutions later.

Of course the day I finally getting around to implementing this is the day Apple introduces a new phone a real browser in it1. Damn! Well, this is definitely going to change things for the better and in time I hope more companies start packaging a decent browser with their phones. And that means, of course, that a having a separate “mobile only” version won’t be necessary. Or at least, won’t be as necessary. Admittedly, I’ve never been a huge proponent of a mobile only web, as vaguely alluded to before. I bought the mobi domain anyway because, well, I’m a bit of a geek and also to grab it before anyone else got their filthy hands on it.

That being said, I thought I’d share how I pulled this off since the mobile market isn’t going to change over night and there are probably some other good uses for either approach.

The ied_if_domain plugin approach

This is what I currently use for my Textpattern driven site. It assumes you know your way around Textpattern and know how to install plugins, modify pages and forms, fiddle with Textpattern tags, and the like2.

  1. First, I created my horrell.mobi domain as an alias to my main one, horrell.ca (here’s some instructions on how to do this at TextDrive, written by yours truly).
  2. Next, I installed and activated the plugin. You can find the plugin here and here
  3. And Finally, I modified a few of my existing page templates, specifically the default one and a custom one I created for the Contact page. At the top, I used a <txp:ied_if_domain domain="horrell.mobi"> conditional to generate my mobile only pages and then my regular page follows after the <txp:else /> statement. There’s an example of how to do this in the plugin help if this doesn’t make any sense.

So, what the plugin does is check to see if my page is being accessed by the mobi domain and, if so, produces a slimmer modified version of my main and contact pages. Pretty neat eh?

Now while working on this I had another idea. I remember thinking “How can I get content out of Textpattern into another site?” You see, I was thinking of having horrell.mobi as a completely separate domain, not an alias, and I was toying with the idea of using PHP to grab content directly from the Textpattern database. I wanted it separate to keep my Textpattern templates simple but, admittedly, messing around with PHP and MySQL didn’t seem like the best approach. Then it hit me: syndication! All I had to do was grab content from my site feed and use that and thus was borne the SimplePie approach.

The SimplePie approach

SimplePie is a nifty API for reading RSS and Atom feeds and with it you can grab whatever feed you like and incorporate it into your own site, or even create a whole new site with it. The upside to this approach is that it doesn’t matter what you use to manage your site, so if you don’t use Textpattern then you’ve got this as an option as well. Now, for my own site I use the ied_if_domain plugin approach, but here’s how you’d do it this way:

  1. Create your mobi domain (instructions on how to do this at TextDrive can be found here, also created/revised by yours truly)
  2. Download SimplePie here
  3. Install SimplePie in the web root of your mobi domain (at TextDrive that would be either /web/public or public_html). You can find installation instructions for how to do this here
  4. Now, create your PHP page template for your site using. An example of how to do this can be found here

And that’s it. There are obviously a lot more steps to it, but you get the basic idea. I’ve been experimenting with SimplePie a little and I created a Christopher Planet of sorts that pulls in feeds from all my sites and services. It’s a work-in-progress, but at least I’ve found a use for my Horrell.info domain.

1 And I have to say, I love that bloody phone. The interface is fantastic and it’s pretty much everything I wanted in a phone.

2 There are some handy SimplePie plugins available for users of Wordpress and MediaWiki as well for incorporating feeds, but I have no idea if there’s an ied_if_domain equivalent.

Adding "post to" links for del.icio.us, digg, and ma.gnolia in Textpattern

Posted 1497 days ago in Archive, modified 1219 days ago

Here’s how to add “post to” links for del.icio.us, digg, and ma.gnolia to individual articles in Textpattern.

Update: Fixed it so the links add urlencoded titles to the output. It’s a bit ugly, but seems to work ok. And I’m having some issues with displaying the PHP code properly, so bear with me.

del.icio.us


post to <a href="http://del.icio.us/post?url=<txp:permlink />&amp;title=<txp:php>$a = title (array ());echo urlencode($a);</txp:php>">del.icio.us</a>

digg

post to <a href="http://www.digg.com/submit?phase=2&amp;url=<txp:permlink />">digg</a>

ma.gnolia


post to <a href="http://ma.gnolia.com/bookmarklet/add?url=<txp:permlink />&amp;title=<txp:php>$a = title (array ());echo urlencode($a);</txp:php>">ma.gnolia</a>

Clicking one of the those links will automatically post a permanent link for an article and, in the case of del.icio.us and ma.gnolia, the title to one of the above services.

Older | →