Matt Gemmell

My new book CHANGER is out now!

An action-adventure novel — book 1 in the KESTREL series.

★★★★★ — Amazon

Thistle categories

Development 2 min read

Categories are now more customisable than ever before.
I <a href="">said previously</a> that 
three main improvements to the blogging metaphor would allow me to consider moving my entire site to a blog 
format. They were:
  • Static includes. Allow the inclusion of static content atop each dynamically-compiled page (and I mean "compiled" in the blogging sense; aggregated from various chunks of content; rather than in the programming sense). Thistle has this already, via its "category info" files - they can contain anything from a sentence of text to a full HTML page, or more.
  • Per-category flavor overrides. Allow a category to specify a flavor which it prefers; its own "default" flavor. Substitute "template" for "flavor" and this applies to any blogging software out there. This instantly solves the "where do I put my Contact form?" problem - you just make a separate category for it, and make that category override the default flavor (template).
  • Sticky posts. Allow a post to insist on being included in the list of most recent posts. This is not at all complicated to implement; you just add a check for some appropriate flag or marker when constructing your list of posts to display. It could readily be another metafile, or even specified in the post's content.

Thistle <a href="">already has</a> static includes 
(actually, they <a href="">can be dynamic</a> too). 
I'm pleased to reveal that we now also have per-category flavor (type/template/whatever) overrides - and more besides. We have two new options:
  • $use_cat_prefs - whether or not to allow categories to override various global settings, including the default template.
  • $cat_prefs_file - name of an optional file in each directory which will be parsed as PHP, and can contain category-specific overrides of essentially any of the global options.
Think about that for a minute. Each category can override what template is used to display it (by redefining <code>$default_type</code> in its 
own category-specific prefs file). Each category can also override things like the blog's name and description (multiple blogs, with multiple 
names, running within a single Thistle installation), <code>$cssURL</code>, <code>$num_entries</code>, <code>$defaultAuthor</code> and 
<code>$defaultAuthorLink</code>, and so on.

That offers a great deal of flexibility - and it's completely optional. Those who just want a single 
blog, with a unified set of templates and a single set of global preferences, get their wish by default. But those who need more customisation 
can now significantly alter each category's behaviour on a case-by-case basis.


Incidentally, other minor improvements today include:
  • The category list now displays hierarchically.
  • Thistle now reads (and evaluates, if appropriate) a category-info file at the root level, as well as in each sub-directory. This is useful for adding some static/dynamic content to the top of the main page of your blog, but not to any category page.

Hopefully we'll have a live demo of Thistle up here before long.