Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
K5 Section Stories Box Boxes
By rusty , Section Code []
Posted on Tue Dec 05, 2000 at 12:00:00 PM PST
Prompted by a request on #kuro5hin, here is the code that creates the left-hand "Section Stories" box on K5. The code follows, feel free to cut and paste. For the template, I use a block called "sec_story_box", which is just the basic container HTML.

I hope that if people have done clever things with output, they'll also post boxes here, so we can all share them. Note the "Boxes" topic. :-)

########################
# Section stories box
# From kuro5hin.org
########################
my $content;

####
# order sections:
#    I do this manually here so that
#    they will appear in the order I want them in.
####
my @sections = qw(
  tech
  culture
  fnp
  media
  news
  internet
  op-ed
  mlp
  Meta
  columns );

# How many stories to show from each section?
my $num_stories = 3;
# How many new diaries to show?
my $num_diaries = 25;

####
# Loop through the above array...
####
foreach my $section (@sections) {
  
  # Get the title and sid for the last $num stories
  my ($rv, $sth) = $S->db_select({
    WHAT => 'sid, title',
    FROM => 'stories',
    WHERE => qq{section = "$section" AND displaystatus = 1},
    ORDER_BY => 'time DESC',
    LIMIT => $num_stories});
  
  # Add the link for the section header
  $content .= qq{
    <B><A HREf="|rootdir|/?op=section;section=$section">$S->{SECTION_DATA}->{$section}->{title}</A>:</B>
    <BR>|smallfont|};
    
  # Add the link for each story
  while (my $story = $sth->fetchrow_hashref()) {
    my $comments = $S->_commentcount($story->{sid});
    
    $content .= qq{
      |dot| <A HREF="|rootdir|/?op=displaystory;sid=$story->{sid}">$story->{title}</A> 
      ($comments comments)<BR>};
  }
  
  # Add the closing "More..." link
  $content .= qq{
    <A HREf="|rootdir|/?op=section;section=$section">more...</A>
    |smallfont_end|
    <P>};
}

####
# New diary list
####

# Get the last $num_diaries Diary entries
my ($rv, $sth) = $S->db_select({
    WHAT => 'sid, aid',
    FROM => 'stories',
    WHERE => qq{section = "Diary" AND displaystatus = 1},
    ORDER_BY => 'time DESC',
    LIMIT => $num_diaries});

# Add the diaries header link
$content .= qq{
    <B><A HREf="|rootdir|/?op=section;section=Diary">New $S->{SECTION_DATA}->{Diary}->{title}</A>:</B>
    <BR>|smallfont|};

# Add each new diary link.
# You could select more stuff above and list, eg, 
# the title of the diary entry
while (my $story = $sth->fetchrow_hashref()) {
    $content .= qq{
        |dot| <A HREF="|rootdir|/?op=displaystory;sid=$story->{sid}">$story->{aid}</A><BR>};
}

# Add the "More..." link for diaries
$content .= qq{
  <BR><A HREf="|rootdir|/?op=search;type=diary;offset=25">More Diaries...</A>
  |smallfont_end|
  <P>};

# And return the content, like normal.
return {content => $content};
< Scoop.kuro5hin.org returns at last! | Timestamps on stories? >

Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Login
Make a new account
Username:
Password:

Related Links
· Kuro5hin
· More on Boxes
· Also by rusty

Story Views
  34 Scoop users have viewed this story.

Display: Sort:
K5 Section Stories Box | 5 comments (5 topical, 0 hidden)
Construction Company (none / 0) (#1)
by Pervez on Sun Apr 14, 2019 at 12:02:42 AM PST

We're truly thrilled I've found this unique info. An incredible web site utilizing thrilling information which may be exactly what we want. You have achieved the first-rate work! Presently click Construction Company Regards regarding fantastic content material.



sad (none / 0) (#3)
by alexsmith2569 on Sat Aug 14, 2021 at 07:00:00 AM PST

Virtual reality technology and the VR casinos are becoming more widespread and accepted by hundreds of thousands of online gamers from all over the world. slot Maintenance & Replacement provisions should be a regular function of the casino's annual budget, which represents a fixed reserve based on the projected replacement costs of furniture, fixture, equipment, building, systems and landscaping.



SAD (none / 0) (#5)
by alexsmith2569 on Fri Oct 29, 2021 at 12:00:10 PM PST

Or you might have been in an autaccident and have trent a car for a time period before getting a new one. rent a car beograd Many airports have at their disposal car rental offices on-site for passengers' ease.



K5 Section Stories Box | 5 comments (5 topical, 0 hidden)
Display: Sort:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search