Re: A simple question about ordering of posts

Chris G <[email protected]> Mon, 1 Feb 2010 16:33:04 +0000
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <20100201163304.GC22124@chris>
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:
> > On Sun, Jan 31, 2010 at 06:23:14PM +0000, chombee wrote:
> > > Having said all this, cb_entryparser doesn't really seem like the right
> > > callback for what you want to do. You don't really want to change how
> > > the entry is parsed from file, just how the entry is rendered. Maybe a
> > > cb_postformat plugin that adds a 'template_name' key to the entry_data
> > > dict.
> > 
> > No, wait! I think you want the cb_story callback, the same one that the
> > readmore plugin uses. Like the readmore plugin does, you can get the
> > entry dict with:
> > 
> >     entry = args['entry']
> > 
> > then use 'bl_type' to see if we're dealing with an index or a permalink
> > page:
> > 
> >     if  entry['bl_type'] == 'file':
> >         # This is a 'file' page, showing a single entry.
> >         pass
> >     else:
> >         # This is an index page (front page or year, month, day, or
> >         # category etc. page) showing multiple entries.
> >         entry['template_name'] = 'story-index'
> > 
> > As a matter of fact, a 'use different story templates for file
> > pages and index pages' plugin would be much simpler and more flexible
> > than the readmore plugin. If you wanted to provide a preview or summary
> > text for each entry like the readmore plugin does, you could just use a
> > metadata field for that.
> > 
> 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
> 
> 
> I'm seeing the logger information in my log file but my template
> (story-index.html) isn't being used instead of the default story.html.
> 
> I'll try adding some debug in the renderer to see if I can understand
> what's going on.

The code in the renderer that looks for the template_name is run
*before* the cb_story plugin, so the template doesn't get changed.

-- 
Chris Green


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com