You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@roller.apache.org by Jennifer Oxelson <ox...@unidata.ucar.edu> on 2011/03/26 19:11:39 UTC

Re: Display subcategory entries when parent category is selected.

Here is a way to do this (it may be a bit of a hack, but it works):

In your weblog.vm file, you will want to modify the $entries that gets 
sent to the _day page to be conditional upon if a category is being 
displayed:

        #set($pager = $model.getWeblogEntriesPager())
        #set($dayPage = $model.weblog.getPageByName("_day"))
       
        #if($model.weblogCategory)
            #set($entries = 
$model.weblogCategory.retrieveWeblogEntries(true)) 
            <h2>Entries for: $model.weblogCategory.name</h2>
            #parse($dayPage.id)
        #else
            #set($map = $pager.getEntries())
            #foreach($day in $map.keySet())
                #set($entries = $map.get($day))  
                #parse($dayPage.id)
            #end
        #end

Also, be sure to assign $day to the entry date in _day if you reference 
it anywhere.

Hope this helps...




> Dave wrote:
> > 
> > You must have missed my earlier response:
> >    http://markmail.org/message/wn3d2zczmtm5zacf
> > 
> > On Mon, Jun 8, 2009 at 2:07 PM, Eric Schmidt<es...@lssaa.wisc.edu> wrote:
> >> Hello,
> >>
> >> I am trying to get entries placed in a subcategory to be shown when a
> >> visitor views a top-level category.  So, for example, if a user clicked on a
> >> link for the Category /Sports, they would see all posts with that category,
> >> along with posts in /Sports/Football, /Sports/Baseball, etc.  Is something
> >> like this possible?
>
>
> Was wondering if anyone has finally done this either by template 
> programming or the java full monty with pagers and such?
>
>
> -- 
> Manos Batsis, Chief Technologist
>   

Re: Display subcategory entries when parent category is selected.

Posted by Dave <sn...@gmail.com>.
On Sat, Mar 26, 2011 at 2:11 PM, Jennifer Oxelson
<ox...@unidata.ucar.edu> wrote:
> Here is a way to do this (it may be a bit of a hack, but it works):
>
> In your weblog.vm file, you will want to modify the $entries that gets sent
> to the _day page to be conditional upon if a category is being displayed:
>
>       #set($pager = $model.getWeblogEntriesPager())
>       #set($dayPage = $model.weblog.getPageByName("_day"))
>             #if($model.weblogCategory)
>           #set($entries = $model.weblogCategory.retrieveWeblogEntries(true))
>            <h2>Entries for: $model.weblogCategory.name</h2>
>           #parse($dayPage.id)
>       #else
>           #set($map = $pager.getEntries())
>           #foreach($day in $map.keySet())
>               #set($entries = $map.get($day))
> #parse($dayPage.id)
>           #end
>       #end
>
> Also, be sure to assign $day to the entry date in _day if you reference it
> anywhere.
>
> Hope this helps...

Thanks for sharing that!

- Dave

--
David M. Johnson
Apache Roller PMC Chair
http://rollerweblogger.org/roller