List Info

Thread: Paginated index pages




Paginated index pages
user name
2007-07-05 18:30:51
Grist is going to create a general news category where we'll
post
approximately 15 news stories each weekday. Each news story
will have
its own page.

We also plan to have an index page that lists the most
recent 20 new
stories in reverse chronological order. Each listing on the
index page
may be either: 1) the entire story (if just a short blurb),
2) an
excerpt of the story, or 3) a summary of the story. Also, an
image might
accompany each listing.

Additionally, we want the index to be paginated so that you
can view the
previous 20 entries and so on until you reach the first
story. Over
time, the number of index pages will get huge.

So, I'm wondering if there are any creative suggestions for
tackling
this so we don't have hundreds/thousands of static index
pages.

Dawn, I noticed you do something similar for The Tyee. I'd
be interested
in learning the rationale for the system you're using.

----------------------------

Chris Schults
Web Production Manager
Grist
710 Second Avenue, Suite 860
Seattle, WA  98104
Phone: 206-876-2020, ext. 204
Fax: 253-423-6487
<http://www.grist.org>


Re: Paginated index pages
user name
2007-07-10 12:01:30
Hey Chris you should have cc'ed me - I don't always read
this list.

On 5-Jul-07, at 7:30 PM, Chris Schults wrote:

> Grist is going to create a general news category where
we'll post
> approximately 15 news stories each weekday. Each news
story will have
> its own page.
>
> We also plan to have an index page that lists the most
recent 20 new
> stories in reverse chronological order. Each listing on
the index page
> may be either: 1) the entire story (if just a short
blurb), 2) an
> excerpt of the story, or 3) a summary of the story.
Also, an image  
> might
> accompany each listing.
>
> Additionally, we want the index to be paginated so that
you can  
> view the
> previous 20 entries and so on until you reach the first
story. Over
> time, the number of index pages will get huge.
>
> So, I'm wondering if there are any creative suggestions
for tackling
> this so we don't have hundreds/thousands of static
index pages.
>
> Dawn, I noticed you do something similar for The Tyee.
I'd be  
> interested
> in learning the rationale for the system you're using.

Yes this is a problem no?

What I have is a list of stories for an entire week of the
Tyee (from  
one monday to the next) separated by Categories.
Since the Tyee publishes daily this seemed like the best
division of  
content. Sites publishing less frequently might want to make
a month  
index.

Each week is represented by a Weekly Archive Story (based on
the  
Daily Archive Story template). The url for that Weekly
Archive Story  
(eg http://t
hetyee.ca/Archive/weekly/2007/07/02/) is linked to in an
 
automatically updated pulldown menu (it's published as a php
file  
which gets included where ever I want to put it).

This is my 'Publish Weekly Site Archive' utility template
which gets  
triggered each time a story.mc (OC Web) is published:

<%args>
# the trigger_story is the articel that may be triggering
this template-
$trigger_story => undef
</%args>
<%once>;
my ($weekly_archive_element_type) =
Bric::Biz::ElementType->lookup 
({key_name => 'weekly_site_archive'});
</%once>
<%cleanup>


my $week_info = $m->comp('/util/get_week_info.mc',
cover_date=> 
$trigger_story->get_cover_date);
my $monday_start_date = $week_info->;

   # Look for an existing weekly archive page
   my ($archive_story) =
Bric::Biz::Asset::Business::Story->list({
      element_key_name => 'weekly_site_archive',
      site_id       => $story->get_site_id,
      cover_date_start => $monday_start_date,
      cover_date_end => $monday_start_date,
      unexpired         => 1, # No expired stories!
      published_version => 1,
      Limit            => 1,
   });


# if a weekly archive story doesn't already exist for this
week make  
one.
unless ($archive_story) {
      $archive_story =
Bric::Biz::Asset::Business::Story->new({
          element_type => $weekly_archive_element_type, #
required
          source__id  => $story->get_source__id, #
required
          site_id     => $story->get_site_id, #
required
          user__id    =>
Bric::App::Session::get_user_id(), # required
          title       => "Stories for week starting
" . $week_info-> 
,
      });

      my ($category) = Bric::Biz::Category->list({
          uri => '/Archive/weekly/',
      });

      $burner->throw_error("There is no weekly
archive category / 
Archive/weekly/ ")
        unless $category;

    # if (!$category) {
     #      die "Could not find category " .
$category;
      #   $category  = Bric::Biz::Category->new({
       #      name => 'Weekly Story Archive',
        #     site_id => $story->get_site_id,
         #    description => "Weekly Site
Archive",
          #   directory => 'Archive',
       #  });
       #  $category->set_parent_id($parent->get_id);
       #  $category->save;
         #$burner->add_msg("Created new archive
category ",$category- 
 >get_name);
    # }

      # Set it up and check it in.
      $archive_story->add_categories( [
$category->get_id ] );
      $archive_story->set_primary_category(
$category->get_id );
     
$archive_story->set_cover_date($week_info->);
      $archive_story->checkin;
      $archive_story->save;
      Bric::App::Util::add_msg('Archive story:
'.$archive_story- 
 >get_title.' created');

# Make sure to mark the current trigger story published so
that it  
will show up in
# the daily archive.
$trigger_story->set_publish_status(1);
$trigger_story->save;

# Publish
$burner->publish_another($archive_story);
Bric::App::Util::add_msg('Archive story: '.$archive_story- 
 >get_title.' published');

} # end creation of new archive story

</%cleanup>


------

This is the get_week_info.mc utility template referenced
above. This  
templates requires the PERL module Date::Manip to be
installed and  
referenced from the bricolage.conf
It's a very powerful module and could be used to do some
many handy  
things with content on a bric site.

<%args>
$cover_date => undef
</%args>
<%once>
use Date::Manip qw(ParseDate Date_GetPrev Date_GetNext
DateCalc  
Delta_Format UnixDate);
</%once>
<%perl>
my $prev = Date_GetPrev($cover_date, "Monday",1);
my $next = Date_GetNext($cover_date, "Sunday",1);
my %hash;
$hash = "2003060900:00:00"; #
Monday, June 9, 2003
$hash = ParseDate('today');
$hash = UnixDate($hash, '%Y');
$hash = UnixDate($hash, '%Y');
$hash = UnixDate($prev, "%Y-%m-%d
00:00:00");
$hash = UnixDate($prev, "%A,
%B %e, %Y"); #  
for use in titles of the page for this weekly archive
$hash = UnixDate($next, "%Y-%m-%d
23:59:59");
$hash =
Delta_Format(DateCalc($hash, $hash 
),0,"%wh");
$hash = UnixDate($prev, "%d %b %y") .
" to " . UnixDate 
($next, "%d %b %y");
$hash = $hash;
return %hash;
</%perl>


-----

My List of stories for the week are produced by this
template.

<!-- Start "Archive Cover" -->
<%perl>
     my $week_info = $m->comp('/util/get_week_info.mc',
cover_date=> 
$story->get_cover_date);
   my %params = (
     element_key_name => 'story',
     publish_status => 1,
     category_uri => 
$story->get_primary_category->get_uri,
     cover_date_start => $week_info->,
     cover_date_end => $week_info->,
     element_key_name => 'story',
   );

my stories =
Bric::Biz::Asset::Business::Story->list(%params );

</%perl>
<div id="index">
<h2>Stories for the week of <%
$week_info-> %></h2>
<?php
$caturi =
"<%$story->get_primary_category->get_uri%>&
quot;;
include
"$_SERVER[DOCUMENT_ROOT]/inc/week_selector/index.html&q
uot;;
?>
<br />
<%perl>

print "<div id='indexlisting'>n";

foreach my $s (stories) {
     my $name= $s->get_name;
     my $uri= $s->get_primary_uri;
     my $deck = $s->get_data('deck');
     my $cover_date = $s->get_cover_date;
     my $primcat =
$s->get_primary_category->get_name;
     print '<h2><a
href="'.$uri.'">'.$name.'</a></h2>'
;
     print '<p
class="deck">'.$deck.'</p>';
     print '<h6>';
     my($cont_list) = $m->comp(
       '/util/contributor_list.mc',
      asset   => $s,
      sep     => ', ',
      final   => ' and ',
      format  => '%f% l',
      default => ''
   );
     print '<br />['.$cover_date.']';
     print '</h6>';
}

  print "</div>n";

</%perl>
<?php
$caturi =
"<%$story->get_primary_category->get_uri%>&
quot;;
include
"$_SERVER[DOCUMENT_ROOT]/inc/week_selector/index.html&q
uot;;
?>
</div>
<!-- End "Archive Cover" -->


----

There's actually lots more to explain and I have limited
time at this  
moment (and need to review in more detail what I did). But
what I can  
do is take time this week to chart out the whole process,
and connect  
the templates together perhaps with a diagram. It could be
part of a  
renewed template base!

Also feel free to ask me any specific questions about this
Chris.  
(I'm in sweltering Toronto right now - not the Tyee
office).

Dawn

>
> ----------------------------
>
> Chris Schults
> Web Production Manager
> Grist
> 710 Second Avenue, Suite 860
> Seattle, WA  98104
> Phone: 206-876-2020, ext. 204
> Fax: 253-423-6487
> <http://www.grist.org>

>

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )