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
Better Section List Boxes
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.
< Edit Queue? | Rio de Janeiro, Brazil >

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

Login
Make a new account
Username:
Password:

Related Links
· Scoop
· More on Boxes
· Also by tneff

Story Views
  41 Scoop users have viewed this story.

Display: Sort:
Better Section List | 1 comment (1 topical, 0 hidden)
sounds great! (none / 0) (#1)
by skloogs on Thu May 09, 2002 at 07:37:38 AM PST

I didn't installed scoop a long time ago, but I was just thinking the same when I noticed that changing the title of a section was not reflected directly on the section bar... then I realized I had to update manually the section_links block...

A great contribution I will try and adapt at once...

Thanks!

phil.

---
Phil
[ A Brazilian Scoop ]



Better Section List | 1 comment (1 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