|
From: chombee <ch...@la...> - 2010-02-02 10:20:26
|
On Mon, Feb 01, 2010 at 06:14:50PM -0500, will kahn-greene wrote:
>
> 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"
>
So it looks like to change the template for every entry that is about to
be rendered you'd have to iterate over entries, something like:
def cb_prepare(args):
request = args['request']
data = request.get_data()
if data['bl_type'] == 'dir':
entrylist = data['entry_list']
for entry in entrylist:
entry['template_name'] = 'story-index'
(Assuming the entries come as dictionaries like that, but you get the
idea.)
|