You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@roller.apache.org by Eric Schmidt <es...@lssaa.wisc.edu> on 2009/06/01 18:23:19 UTC

Limit number of posts on just the home page.

Hello,

I am creating a blog that will feature posts from 40 departments each 
month.  I would like to have only one introductory post appear on the 
main home page with links to the different categories where the rest of 
the posts will appear.  Is there a way to limit the number of posts to 1 
for the main page but allow for multiple posts to appear when a specific 
category or tag is viewed?

Thanks,
Eric Schmidt


Re: Limit number of posts on just the home page.

Posted by Dave <sn...@gmail.com>.
On Mon, Jun 1, 2009 at 12:23 PM, Eric Schmidt<es...@lssaa.wisc.edu> wrote:
> I am creating a blog that will feature posts from 40 departments each month.
>  I would like to have only one introductory post appear on the main home
> page with links to the different categories where the rest of the posts will
> appear.  Is there a way to limit the number of posts to 1 for the main page
> but allow for multiple posts to appear when a specific category or tag is
> viewed?


Yes, but you'll have to do some template programming to make it work that way.
Check the Roller Template Author Guide for more information.

To get you started I have included a page template that's designed to
be used as the main page of a front-page blog in Roller. I think it
does basically what you want (but with overly simple layout and no
styling).

My example displays a list of the front-page blog categories and next,
any weblog entries that are "pinned to main." If you click one of the
categories you'll see the most recent entries in the category and if
there are a lot, Next/Prev navigation links.

As a global admin user in Roller you can "pin" weblog entries to
indicate that they should be kept on the front page of the site. So,
you can chose one or two entries to be on the main page of the site,
when a category is not selected.

- Dave



<html>
<head>
</head>

<body>

<h2>Categories</h2>

<a href="$url.home">Main</a>
#set($categories = $model.weblog.getWeblogCategories("/"))
#foreach($c in $categories)
  <a href="$url.category($c.path)">$c.name</a>
#end
<br />
<br />

#if($model.weblogCategory)

  <h2>Entries in category: $model.weblogCategory.name</h2>

  #set($pager = $site.getWeblogEntriesPager(365, 20))
  #foreach($e in $pager.items)
    #if($velocityCount < 20)
      <a href="$utils.escapeHTML($e.permalink)">
        $utils.truncateNicely($utils.removeHTML($e.title), 50, 50, "...")
      </a>
      <br />
      <a href="$utils.escapeHTML($e.website.URL)">$e.website.name</a>
      #if($e.category.name) | $e.category.name #end
      #if($e.pubTime) | $utils.formatDate($e.pubTime, "EEEE MMMM dd, yyyy") #end
      #if($e.creator.screenName)| By $e.creator.screenName #end
      <br/>
      $e.displayContent
      <br/>
      <br/>
    #end
  #end

  #if($pager.nextLink)
    <a href="$pager.nextLink">&lt; $pager.nextName</a>
  #end
  #if($pager.nextLink && $pager.prevLink)
    &nbsp;|&nbsp;
  #end
  #if($pager.prevLink)
    <a href="$pager.prevLink">$pager.prevName &gt;</a>
  #end

#else

  <h2>Pinned Entries</h2>

  #set($entries = $site.getPinnedWeblogEntries(5))
  #foreach($e in $entries)
    <a href="$utils.escapeHTML($e.permalink)">
      $utils.truncateNicely($utils.removeHTML($e.title), 50, 50, "...")
    </a>
    <br />
    <a href="$utils.escapeHTML($e.website.URL)">$e.website.name</a>
    #if($e.category.name) | $e.category.name #end
    #if($e.pubTime) | $utils.formatDate($e.pubTime, "EEEE MMMM dd, yyyy") #end
    #if($e.creator.screenName)| By $e.creator.screenName #end
    <br/>
    $e.displayContent
  #end

#end

</body>
</html>