return to first page linux journal archive
keywordscontents

Listing 8. view-stories.html

%# -*- mmm-classes: mason -*-
<Head><Title>Latest news</Title></Head>
<Body>
<H1>Latest news</H1>
% if (@stories) {
% foreach my $story (@stories) {
<H2><% $story->{headline} %></H2>
<P><% $story->{body} %></P>
% }
% } else {
<P>No news in this category.</P>
% }
</Body>
<%once>
my $dbh;
</%once>
<%init>
# Connect to the database, if we have not already
# done so
$dbh = $m->comp("database-connect.comp");
# Get the stories
my @stories = $m->comp("get-news.comp",
            category_id => $category_id,
            how_many => $how_many);
</%init>
<%args>
$category_id
$how_many
</%args>