Re: A simple question about ordering of posts

will kahn-greene <[email protected]> Mon, 01 Feb 2010 18:14:50 -0500
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
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

------------------------------------------------------------------------------
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