|
From: will kahn-g. <wi...@bl...> - 2010-02-01 23:14:59
|
On 02/01/2010 05:47 PM, Chris G wrote:
> How can one change the template for just one thing though at that
> stage? I want to change just the story template when certain
> conditions are met.
The prepare callback gets the entire entry list. So when the certain
conditions that you want met are met, you make the change to the
template_name variable in the entry in the entry list.
For example, if I want the first entry that is going to be shown to use
a template story_big_size that I wrote that's just like my story
template, but the font size is bigger so that the entry is more
prominent at the top of the page, I'd do something like this:
def cb_prepare(args):
# only thing in the args dict is the request object
request = args["request"]
# the entry list is in the data section
data = request.get_data()
entrylist = data["entry_list"]
if len(entrylist) > 0:
first_entry = entrylist[0]
first_entry["template_name"] = "story_big_size"
Say I only wanted to do this if PyBlosxom is rendering a category index
and not a specific entry. I'd do something like this:
def cb_prepare(args):
# only thing in the args dict is the request object
request = args["request"]
# the entry list is in the data section
data = request.get_data()
entrylist = data["entry_list"]
if data["bl_type"] = "dir" and len(entrylist) > 0:
first_entry = entrylist[0]
first_entry["template_name"] = "story_big_size"
Does that make sense? This kicks off after PyBlosxom has figured out
what it's rendering, but before it actually gets rendered.
/will
|