23/01/07

hReview in Textpattern

That last post was a little test in using the hReview Microformat in Textpattern. I think it worked!

One of Textpattern’s great features is the ability to use a different ‘form’ (the template that specifies how posts are marked up) that each post uses. With this in mind, all you need to do is create a different article form called ‘hReview’ and specify that any time you do a review on a Textpattern blog.

I’ll come to the actual markup of the form in a moment, but first I just want to show you how I’ve used the Content > Write tab to write the review.

In this example, all I added were 2 custom fields (via Admin > Preferences > Advanced), ‘URL’ and ‘Rating’, but you may want to add more for fields such ‘Item Type’.

Then I entered the review as follows:

TXP Field name Microformat Class TXP Tag
Title Item <txp:title />
Excerpt Summary <txp:excerpt />
Body Description <txp:body />
Article Image* Photo <txp:article image class="photo" />
Rating (custom field) ** Rating <txp:custom_field name="Rating" />
URL (custom field) URL <txp:custom_field name="URL" />

*The Textpattern ID of the image

**Entered as a number from 1-5

I then chose ‘hReview’ from the ‘Override form’ dropdown before publishing. However, you can’t choose that until you create the form, so let’s get down to the nitty gritty! Create a new form called ‘hReview’, choose ‘article’ from the type dropdown, and add the following code:


<div class="hreview">
  <h2 class="item"><txp:permlink class="fn"><txp:title /></txp:permlink></h2>
  <p><abbr class="dtreviewed" title="<txp:posted format="%Y%m%d" />"><txp:posted format="%B %e, %Y" / ></abbr>
  <span class="reviewer vcard">  by 
    <span class="fn"><txp:author /></span>
  </span>
  <txp:if_custom_field name="URL">
  <p><strong>Website:</strong> <a href="<txp:custom_field name="URL" />"  class="fn url" rel="bookmark"><txp:custom_field name="URL" /></a></p>
  </txp:if_custom_field>
   <div class="summary">
    <txp:excerpt />
   </div>
<div class="description">
    <p>Rating: <span title="<txp:custom_field name="Rating" />" class="rating"> <txp:custom_field name="Rating" /></span> out of 5</p>
<txp:article_image wraptag="p" class="photo" />
<txp:body/> 
</div>
</div>

A lot of this is self-explanatory. The review description is output wherever you put <txp:body />, the item name is output wherever you put <txp:title />. There are a few places where it’s probably worth talking through what’s going on.

Date

The txp tag @23.01.07 has an attribute “format” which allows you to customise the date using PHP’s strftime strings:

<abbr class="dtreviewed" title="<txp:posted format="%Y%m%d" />"><txp:posted format="%B %e" />, <txp:posted format="%Y" />

Doing this uses the published time information and displays in ‘human readable’ form:

< txp:posted format="%B %e, %Y" / >

as well as ISO for the title attribute:

<txp:posted format="%Y%m%d" />">

Handy if you also want to use Textpattern to display events in hCalendar format (which I’ll cover in another post).

Rating

Whatever number is entered into the Rating field is output in the title attribute as well as the text:

<p>Rating: <span title="<txp:custom_field name="Rating" />" class="rating"> <txp:custom_field name="Rating" /></span> out of 5</p>

There are other possibilities here, such as: class="rating star<txp:custom_field name="Rating" />" and then using image replacement to style the span with the resulting class name (star1, star2 etc.). The hReview creator suggests using HTML entities to display a star rating, for which we’d need to use the conditional tag <txp:if_custom_field>, e.g:

<txp:if_custom_field name="Rating" val="1">★☆☆☆☆</txp:if_custom_field>

This is what I used on the first review, but as Mr Oxton pointed out, this isn’t very ‘human readable’ to things like screenreaders, so I intend to implement the image replacement/class method above.

It’s a wee bit of sweat to set it up, but you have, you’ve got a form that can be called up anytime you want a review on your site to be marked up as a hReview!

Technorati TagsTags: , ,

03/12/05

Textpattern Notes: New Tag goodness

Back when Texpattern was still gestating, many plugins were written to fill holes in its templating options, but its come a long way since then. Every day I’m finding new tags that allow me to keep plugins down to a minimum.

If you haven’t already, you really need to bookmark these pages: Alphabetical Tag Listing and Attributes Cross Reference on the Textpattern wiki documention, called “TextBook”. This an amazing resource, especially if you adopted Textpattern back in the days when it had no documentation. There are lots of gems in here, so I thought I’d dig some out, in case they’re new to you as well.

Read the rest…

Technorati TagsTags: , ,

04/10/05

Textpattern Notes: Comments revisited

In Textpattern notes parts 2, and 4 I explained how to hack TXP’s comments system to acheive certain effects. A lot has changed since then (especially with v4.0), and I need to update the methods. I’m now running TXP with no hacks whatsoever, and that’s a very good feeling!

Read the rest…

Technorati TagsTags: , ,

12/09/05

Ideal OS X Text Editor?

That last post got me thinking. My ideal text editor for OS X is out there, but all the elements I want are in different apps! If I could somehow melt these bits together (like melting 4 chunky kit-kats together and pretending they’re the old style kit-kats), these are the ingredients I would use.

  • SubEthaEdit’s collaboration ability, split-view, web preview (just prefer it to Textmate’s), code navigation and general cocoa feel. Textmate allows you to navigate the code, but its a separate window. skEdit puts its navigation menu in the toolbar (where it should be), but SubEthaEdit’s implementation includes icons that find easier to scan.
  • skEdit’s code hinting, colour blender and project management. Its code hinting makes writing CSS and HTML so quick and painless, and its the only one that allows you to create a list of projects to open. In Textmate, I’ve got around this by keeping a folder of aliases to ’.tmproj’ files in my dock for quick and easy project opening.
  • Textmate’s project drawer, code-folding, bundle editor and CSS & HTML validator. skEdit has snippets, but Textmate takes this much further with its bundle editor. Unfortunately, Textmate doesn’t use a standard cocoa textfield, so services items such as lipServiceX’s Generate Lorem Ipsum aren’t accessible.

With the exception of a built-in Textile filter (which can be added in Textmate, as Drew shows), this would do me nicely thankyou!

Read the rest…

Technorati TagsTags: , ,

26/05/05

Textpattern Notes 6: Overriding Forms

One of the most frequent questions I get asked about my Textpattern setup is how I do change content per article on the journal homepage. The majority of the time I have excerpts of each article with a link to read the full article, but sometimes I have very short articles that are shown in their entirety, and these just have the link for Permalink. This is all done with ‘override form’.

Read the rest…

Technorati TagsTags: ,

31/03/05

Safari tabs for Firefox updated

How to improve the original tabs hack with close buttons.

Read the rest…

Technorati TagsTags: , , , ,

27/01/05

Textile previews in Ecto and MarsEdit

I’ve had problems getting Textile previews to work in these apps, and wanted to share here the solutions in case anyone else has been in the same boat.

Read the rest…

Technorati TagsTags: , , ,

04/12/04

Survey Results

The votes for comp apps and text editors have been counted.

Read the rest…

Technorati TagsTags: , , , , ,

18/11/04

Sidebar links with de.licio.us

Update – For various reasons I’ve decided to keep going with my Textpattern version, but the information is here if you need it. Word of warning though – make sure you know what you’re doing with the cache.

I’ve just moved my sidenotes links from the inbuilt textpattern system to de.licio.us, a service I’ve been using more and more over the last couple of months. There was nothing wrong with the Textpattern method, its just that using de.licio.us makes these links a little easier to find again. Now I post my sidenotes using Cocoalicious, a beautfully simple cocoa interface to the de.licio.us api. If the site I want to post is in Safari, I just select ‘New post from Safari’ in Cocoalicious, and it pre-populates the fields. Each tag in de.licio.us can have its own RSS feed, so all that was left was how to integrate the links on my journal pages.

Read the rest…

Technorati TagsTags: , ,

21/09/04

Textpattern notes part 4

A few more Textpattern odds and sods. How to add entry url’s to email notifications, basic integration of Textpattern and Photostack, more choices for permalink tags and overriding forms per entry.

Read the rest…

Technorati TagsTags: , ,

17/08/04

Forcing scrollbars (now even better)

Forcing scrollbars

The massive trend of centering content horizontally brings with it a small problem. When moving from pages with short to long content, a nasty shift happens. The only way to avoid this is to force scrollbars to appear all the time. Here are a few solutions…

Read the rest…

Technorati TagsTags: , , ,

10/08/04

Tweaking Firefox with CSS

I’ve only recently discovered the power of Mozilla’s ‘user content’ files that reside in the profile directory. I’d created a user.js file to add preferences for things like pipelining, but I’d never looked into the others – ‘userChrome.css’ (for tweaking the interface), and ‘userContent.css’ (for tweaking the web page display).

Here are the tweaks and customisation that I’ve done to my copy of Firefox to give you an idea. First of all, make life easy for yourself and install Chris Neale’s ChromEdit extension. This allows you to edit the user files from within Firefox. Once you’ve restarted, ‘Edit User Files’ will appear under the Tools menu.

Read the rest…

Technorati TagsTags: , , ,

02/08/04

IE Whitespace Bug

Its been a sort of Holy Grail for me (well maybe a Holy Teacup) to find a solution the IE Whitespace bug. If you’re not familiar with this, then you probably haven’t applied display:block to links within an unordered list. Adding this CSS property creates a solid ‘button’ out of what would’ve been a humble inline link, one that can be sized and prettied up as you like. The trouble is, IE windows adds another line height between all these links – unless you remove every bit of whitespace from the HTML.

Read the rest…

Technorati TagsTags: , , , ,

04/07/04

RSS sidebar in Safari

Those of you who are registered users of Saft will now have the latest preview version with the new sidebar feature. The plugin nature of the sidebar (each panel can be a web page, perl script or shell script) has got me wondering about what useful little widget I could put in there.

Here’s my first idea. After hacking the excellent Feedonfeeds news aggregator script, I’ve made a little OS X style RSS sidebar. Feedonfeeds is a php/MySQL solution that you can install on your site, rather than using a desktop client. From here I can click the unread number to view the latest feeds, the grey number to see all the recent entries, and the blog name to go straight to the site. The first 2 open in a simplified format – very like the RSS Reader/Sage extension for Firefox, and the upcoming Safari RSS reader.

Read the rest…

Technorati TagsTags: , , ,

24/06/04

Textpattern notes Part 2

Please note the information in this entry is now superceded

For the second of my notes on Textpattern conversion, I’m going to cover just one subject : hacking the txp comment system.

Purpose of this hack:
Change the recorded comments to display as <div>’s rather than <li>’s, with alternating background colours and sequential numbering. Change the comment form to allow live previews to be used.

Read the rest…

Technorati TagsTags: , ,

22/06/04

Textpattern notes Part 1

As and when I get time, I’m going to post some more information about this site’s conversion over to Textpattern. I’m going to evangelise it until I’m blue in the face.

There were quite a few little tweaks I had to make, but here are just a few notes to be getting on with…

Clean URLs for the news feeds

Create your folder structure (such as /feeds/rss/) and place the following code in an index.php file in that last directory:

<?php
header('location: /?rss=1&section=journal');
?>

Just replace ‘rss’ for ‘atom’ if you need that feed too. I’ve also specified that the feed should come from my journal section, but you if you just run Textpattern as a blog you leave this out. Thanks to Drew McLellan of Allinthehead for this one.

Read the rest…

Technorati TagsTags: , ,

24/04/04

Actionscript recommendations?

Lets say you knew someone who could use Flash. They could use use the timeline, animate/tween etc, but really wanted to get to grips with the actionscript side. What book/site/tutorial CD would you suggest they look at? “ActionScript for Flash MX: The Definitive Guide” by Colin Moock looked like a good bet, but please leave thoughts if you have them.

Sorry, its a cheeky use of a blog, but you’re all such nice, helpful people…

Technorati TagsTags: , ,

30/12/03

Live Comment Previews

Hope you all had a good Christmas! In response to the most queries I’ve ever received about the site (_both_ of Hicksdesign’s readers asked about this one!), here’s an explanation of the live comment previews I’ve started using.

While looking for a solution to MovableType’s cgi-only comment preview pages (cgi means no php includes) I discovered an alternative – live comment previews. An article at Scriptygoddess, explained how javascript can be used to write form information to a <div>, refreshing everytime a key is pressed. It’s pretty basic, no line breaks of html previews, just the raw text, but the <div> could reuse the same CSS as your comments. Leading on from this, there was an enhanced version posted at Glimpse of a Girl which allowed line breaks to be shown.

Read the rest…

Technorati TagsTags: ,

22/10/03

php snippet

I’ve found the PHP stylesheet switcher from ALA immensely useful, as it also opens up an easy way to provide different content, depending on the style chosen.

For example, to make sure that the navigation is displayed ‘flat’ in the diet version of hicksdesign (by removing the javascript), I’ve used the following php snippet:


<?php if ($sitestyle=="plain") echo "<script type=\"text/javascript\" src=\"/js/global_plain.js\"></script>"; else echo "<script type=\"text/javascript\" src=\"/js/global.js\"></script>";
?>

If ‘plain’ has been chosen by the user, it inserts the link to an external javascript file containing no menu scripts. If the user has chosen the default, or not chosen at all, it inserts the link to the version that has. (This won’t work in Mozilla if the user changes style using the browser menu). Using the css property display:none will just hide it from view, but this means you can decide what content goes into the HTML before it actually gets to the user.

Read the rest…

Technorati TagsTags:

Elsewhere

The Rissington Podcast - weekly shenanigans with Jon Oxton

Hicksmade - unique handmade goods by Leigh Hicks width=

archives

love

Brit Pack: A proud member I love Omniweb Coda Segment Publishing I buy my type from Veer The Forgiveness Project