The Hickensian

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.

Shortstats

In order to get Texpattern and Shaun Inman’s Shortstats working in harmony, I placed the shortstat include at the bottom of each of the section text files in the root. For example, in the ‘article’ file you would have :

<?php
include "./textpattern/config.php";
$s = "article";
include $txpcfg["txpath"]."/publish.php";
textpattern();
include($_SERVER["DOCUMENT_ROOT"]."/shortstat/inc.stats.php")
?>

Mixing hard coded and txp driven pages

In the about section, I needed to do something clever for the ‘about hicksdesign’ page, wheareas the colophon and the contact pages would essentially be just articles.

Using the If_category plug-in by Matthew Moss, I set up the ‘about’ section page to show the hard coded content if the category=hicksdesign, and just a plain article for the others:

<txp:mdm_if_category category="hicksdesign">
....hard coded content in here....
</txp:mdm_if_category>
<txp:mdm_if_category category="colophon,contact">
<txp:article limit="1" form="about" />
</txp:mdm_if_category>

This method is also used to alter the layout between the desktops page and the other downloads pages.

Comments | RSS

No.1

Wilson said 2058 days ago:

Part 1, awesome. I can’t wait to read all the other things you figured out about textpattern that are still stumping me…
No.2

Foster said 2058 days ago:

I’ve been lurking at your site for a few months now. It is always fun to read, informative and inspiring. Not to mention, beautiful.

Today, I bought a TextDrive account and will be using TextPattern…I look forward to standing on your shoulders.
No.3

Foster said 2058 days ago:

Just to clarify…

The reference is to: “Standing on the shoulders of giants.”

Not sure who wrote/said it first.

:)
No.4

Hans said 2058 days ago:

Oi vey, that’s gotta be the funniest typo yet. You make Drew sound like he belongs to the Lenon clan or something.

It’s Mc_Lellan_.
No.5

Jon Hicks said 2058 days ago:

come again?
No.6

Anne said 2058 days ago:

Why don’t you add a simple line to your .htaccess folder?

Redirect permanent /rss.php http://www.hicksdesign.co.uk/?rss=1&section=journal

Note that you should not use relative links for the ‘location’ header.
No.7

Justin Low said 2058 days ago:

Great job with the comments Jon!

I must get around to trying ShortStats. In my next redesign, perhaps.
No.8

Rad S. said 2058 days ago:

I used mod_rewrite for friendly feed URLs:

RewriteEngine On
RewriteRule /feeds/(rss|atom)/? /?$1=1&section=journal
No.9

Rad S. said 2058 days ago:

Oops, that should be:

RewriteEngine On
RewriteRule /feeds/(rss|atom)/? /?$1=1&section=journal [NC,L]
No.10

Hans said 2058 days ago:

On the default font size, your wonderful Textpattern button (down below) is knocked off the line and down and to the left.
No.11

Tom Graham said 2057 days ago:

Hi,
I noticed the stats program you’ve been using; its nice, but not as nice as bbclone.

http://bbclone.de/

BBclone is a lot sexier, and more to the point, useful!

tom
No.12

Jon Hicks said 2057 days ago:

Tom -ugh, I disagree, (going by the demo on their site) BBclone doesn’t tell me referrers or search strings. It also doesn’t break down the browsers into versions – which is essential for me. Conversely, I don’t need to know about ‘extensions’ or hosts. Shortstats has nicer design too!
No.13

Jeff Clark said 2057 days ago:

My personal preference is Webalyzer or Awstats. I don’t know if either is free/open-source since my hosting company gives it to me, but Awstats is just sweet. Not sexy by any means, but sweet.

Well check that out. I don’t know if I’ve just missed it or not, but it looks like the live preview is back! I don’t know how you do it Hicks, but I like it.
No.14

Yukki Pospel said 2056 days ago:

ShortStat are really good. Another cute and clean stats collector – AudiStat found http://adubus.free.fr/audistat/
No.15

Anton said 2051 days ago:

Jon, to get ShortStats to work with Textpattern (on TextDrive) for a non-root folder (domain.com/foo/), would I do anything differently? Love your site, and your contributions to the web.
No.16

Anton said 2051 days ago:

Nevermind on my previous post – I put shortstats in my root and I get stats for my whole site. Fancy that.
No.17

Hans said 2050 days ago:

You might also want to add the code for blocking IP addresses and domains… Shaun said he’d add it to the next version, but I was impatient. Andrew posted some code; here’s it again for anybody who needs it:

SI_sniffKeywords($url);

// this technique is an adaptation of
// IP/BotWhack for Textism’s Refer tool
// add IP’s or hosts below as needed
$ban[] = ‘xx.xx.xxx.xxx’;
$ban[] = ‘crapflooderdomain.com’;

// set flag that will be tripped if IP or host is found to match
$OK = TRUE;

// check for IP or referer host in ban list
if(is_array($ban)) {
foreach($ban as $a) {
if (strpos($ip,$a) !== FALSE || strpos($domain,$a) !== FALSE) { $OK = FALSE; }
}
}

// wrap original SQL query in a flag checker if statement
if ($OK) {
$query = “INSERT INTO $SI_tables[stats] (remote_ip,country,domain,referer,resource,user_agent,platform,browser,version,dt)
VALUES (’$ip’,’$cntry’,’$domain’,’$ref’,’$res’,’$ua’,’$br[platform]’,’$br[browser]’,’$br[version]’,$dt)”;
@mysql_query($query);
}
}
No.18

Marco said 2042 days ago:

Great tutorial, except somehow it did not work out for me: the comments are not alternating colors, the comment box is reduced to a 40×40px box, and the preview does not work.

Would it be possible to post the entire hacked comment script and the other required pieces (CSS, form) to the TextPattern forum and post a link to the post?

The Hickensian is the journal of Hicksdesign, a creative partnership of Jon & Leigh Hicks. Read more about us.

Journal RSS Feed

POWERED by FUSION

Elsewhere

The Rissington Podcast - weekly shenanigans with Jon Oxton

Hicksmade - unique handmade goods by Leigh Hicks

Hickr | RSS

Contact

Hicksdesign

Island House

Lower High Street

Burford

Oxfordshire, UK

OX18 4RR

+44 (0)7917 391 536

Click to download my vCard Download vCard

I am currently working full-time with Opera, and not taking on any new projects