Re: A Post's Categories
Georg Bauer <gb-BRhJDZTO+/[email protected]> Sat, 27 Mar 2004 20:36:22 +0100
| Newsgroups | gmane.comp.pythin.pyds.devel |
|---|---|
| Message-ID | <r02010100-1028-077D4BF1802611D8A517000A9573A72A@[10.0.0.145]> |
Hi!
> First, how to 'browse' available Cheetah template vars and PyDS-post
> data structures?
Uh, that's problematic. Best way to do is go into the tools source and
check the source of the called method. For example the
WeblogRendering.tmpl uses the getRecentPosts method and that includes
building the hash that is returned. Macro programming in PyDS is still a
bit hacky, due to missing documentation :-)
> <tr><td align="left"><span class="smallfont">
> #for $cat in $post.$categories
> <a href="/weblog/$cat.name">$cat.name</a>
> #end for
> </span></td></tr>
Almost right. But the post-hash has the categories element filled with a
list of the categories by name. So the following should work:
<tr><td align="left"><span class="smallfont">
#for $cat in $post.$categories
<a href="/weblog/$cat">$cat</a>
#end for
</span></td></tr>
Another - maybe nicer - option would be to do what
BlogmarkRendering.tmpl does (blogmarks and weblog postings are very
similar, so you can "steal" code from the other ;-) ):
#if $post.categories
<tr><td align="left"><span class="smallfont">
#for $cat in $post.categories
<a class="category-reference"
href="$current.getStaticUrl(category=$cat)" title=
"$_('More blogmarks like this one')">$cat</a>
#end for
</span></td></tr>
#end if
This takes care of the case where you don't have any categories and
don't want an empty row to be rendered.
One way to play with stuff is the monitor - that way you directly call
the methods and see what they return. Or call the macros by XMLRPC.
getRecentPosts should be easily callable by XMLRPC and so you see what
is returned.
> I was trying to draw from the code in the weblogTemplate edit section
> where it iterates thru some categories
> and checks off the category boxes, but different vars must apply in
the
> rendering context.
Yep, WeblogRendering and WeblogTemplate are a bit different, as they are
rendering for different destinations (Desktop and Cloud).
> [FYI, this code caused PyDS to stop noticing any subsequent blog entry
> changes or additions; the event log
> showed no activity except for the regular heartbeat event. This had me
> panicking; fortunately, restarting PyDS
> got things righted.]
Weird.
bye, Georg