Go to content Go to navigation Go to search

Tread lightly on the things of earth

Mike’s weblog about computing, politics, and faith (a progressive view)

Tags: , , Textpattern: Simple per-section masthead image selection

I find a simple way to implement a per-section masthead image in Textpattern.

I spent a few minutes trying to figure out how to declare a different masthead image per section in Textpattern. After examining all the plug-in functionality available, I suddenly realized this works very simply:

In the Textpattern page or form declaring the masthead div, make the div section-specific like so (works for sure in 1.0RC5):

<div id="masthead" class="mastimg_<txp:s />" />

which renders as, say,

<div id=”masthead” class=”mastimg_weblog” />

Then create a one-line CSS rule in your stylesheet for each of your sections:

.mastimg_about { background: url(/images/1.jpg) no-repeat; }
.mastimg_notes { background: url(/images/2.jpg) no-repeat; }
.mastimg_weblog { background: url(/images/3.jpg) no-repeat; }

and so on.

This now seems almost too obvious to mention. But it wasn’t obvious to me a couple of hours ago. :-)

(Not yet implemented here; realized during implementation of my friend Hal’s site.)


2005-08-21 insert: This is simpler still —

In your page template just declare

<body id="<txp:s />">

which renders in each page of a particular section as, say,

<body id=”weblog” />

Then style each section’s masthead with a rule like

#weblog #masthead { background: url(/images/3.jpg) no-repeat; }