Better Section List
|
|
By tneff , Section Code [] Posted on Wed May 08, 2002 at 12:00:00 PM PST
|
|
One thing I didn't like about the default Scoop distribution was that the section links in the header (block section_links) was just a hard-coded list of HREF's that you have to remember to edit every time you add, remove or change a section -- and it stays static for every visitor, regardless of whether they have the privilege to see all the sections listed. So I fixed it...
|
I wrote a box called section_list (using template empty_box) as follows:
my @sections = @{$S->get_sections()};
sub make_sec_href($$) {
my ($sec,$title) = @_;
my $href = "|rootdir|";
$href .= "/section/$sec" if $sec;
return "<a href=\"$href\">$title</a>";
}
my @links = ( make_sec_href("", "Home"),
make_sec_href("__all__", "Everything") );
for my $s (@sections) {
if ($S->have_section_perm('norm_read_stories', $s)) {
push @links, make_sec_href($s, $S->{SECTION_DATA}->{$s}->{title});
}
}
my $content = join(' · ',@links);
return {'content'=>$content};
Then I modified the section_links block to say:|norm_font|
|BOX,section_list|
|norm_font_end|
Now I can have 'backroom' sections for editors or admins, as well as stuff that's only visible to logged-in users, and the list of links on each page is adjusted accordingly. |
|
Story Views
|
42 Scoop users have viewed this story.
|
|