22/06/04

Comments 18

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.

Technorati TagsTags: , ,

Comments | RSS

#1

Wilson said 1539 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…
#2

Foster said 1539 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.
#3

Foster said 1539 days ago:

Just to clarify…

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

Not sure who wrote/said it first.

:)
#4

Hans said 1539 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_.
#5

Jon Hicks said 1539 days ago:

come again?
#6

Anne said 1539 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.
#7

Justin Low said 1539 days ago:

Great job with the comments Jon!

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

Rad S. said 1538 days ago:

I used mod_rewrite for friendly feed URLs:

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

Rad S. said 1538 days ago:

Oops, that should be:

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

Hans said 1538 days ago:

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

Tom Graham said 1538 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
#12

Jon Hicks said 1538 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!
#13

Jeff Clark said 1538 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.
#14

Yukki Pospel said 1537 days ago:

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

Anton said 1532 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.
#16

Anton said 1532 days ago:

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

Hans said 1531 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);
}
}
#18

Marco said 1522 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?

Elsewhere

The Rissington Podcast - weekly shenanigans with Jon Oxton

Hicksmade - unique handmade goods by Leigh Hicks width=

love

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