|
From: Chris G <cl...@is...> - 2010-02-01 19:04:39
|
On Mon, Feb 01, 2010 at 05:36:03PM +0000, chombee wrote:
> On Mon, Feb 01, 2010 at 04:19:10PM +0000, Chris G wrote:
> > On Sun, Jan 31, 2010 at 06:54:46PM +0000, chombee wrote:
> > Well I've tried tha above and, so far, I can't get it to work. I'm
> > detecting the 'file' and 'dir' for single/multiple entries OK.
> > So my plugin looks like this:-
> >
> > def cb_story(args):
> >
> > logger = tools.get_logger()
> >
> > e = args['entry']
> >
> > if (e['bl_type'] == 'dir'):
> > logger.info("It's a 'dir' so set the template_name to 'story-index'")
> > e['template_name'] = 'story-index'
> >
> > return args
>
> Sorry, I think the key is 'template' not 'template_name'. In another
> callback it was definitely 'template_name', but the docs for cb_story
> say:
>
> "The template used is typically the story template, but we allow entries
> to override this if they have a template property. If they have the
> template property, then we’ll use the template of that name instead."
>
> Funny, I notice that the docs also say: "Functions that implement this
> callback must return the input args dict whether or not they adjust
> anything in it." But the cb_story in the readmore plugin doesn't return
> anything.
>
It's supposed to return args (the incoming argument list) as that's
where the story content that gets displayed (the $body) comes from.
That's how I'm changing from 'ordinary format' to 'index format' at
the moment, be setting the 'body' in the returned args to nothing.
Looking at the code I'm pretty sure the key is 'template_name', it
refers to that quite a lot in the rendered. However, as I said, I
think the renderer looks for the alternative 'template_name' *before*
cb_story() is called.
Just tried 'template' instead of 'template_name', no difference.
--
Chris Green
|