Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

[Bricolage-General] Retrieving/Displaying Contributors?

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


Andrew.Baio at dfafunds

Feb 25, 2002, 3:43 PM

Post #1 of 2 (946 views)
Permalink
[Bricolage-General] Retrieving/Displaying Contributors?

When working with templates, how can I retrieve
the contributors associated with a story?

I looked in the docs, but still can't figure
it out. I want to print out the Writer names
and contact information that I've associated
as Contributors to my stories.

-- Andy.

----------------------------------------------
Andrew C. Baio
Webmaster, Dimensional Fund Advisors
andrew.baio [at] dfafunds (310) 576-1126
----------------------------------------------

_______________________________________________
Bricolage-General mailing list
Bricolage-General [at] lists
https://lists.sourceforge.net/lists/listinfo/bricolage-general


sam at tregar

Feb 25, 2002, 5:16 PM

Post #2 of 2 (894 views)
Permalink
Re: [Bricolage-General] Retrieving/Displaying Contributors? [In reply to]

On Mon, 25 Feb 2002, Andrew Baio wrote:

> When working with templates, how can I retrieve
> the contributors associated with a story?
>
> I looked in the docs, but still can't figure
> it out. I want to print out the Writer names
> and contact information that I've associated
> as Contributors to my stories.

Here's some code I wrote to produce a byline string of the form:

by Sam Tregar, Sammy Hagar (Photographer) and Martin Short (Illustrator)

That is, Writers first with no type in parens followed by other
contributors with a singular version of their type name in parens. It's
written to be used in an HTML::Template burner .pl file but it should be
easy to port to a Mason .mc file if that's what you're using.

my( $byline, @contributors, $person, $type, @writers );
foreach $person( $story->get_contributors() ) {
$type = $person->get_grp->get_name();
if( $type eq 'Writers' ) {
push( @writers, $person->get_name() );
} else {
$type = s/s$//;
push( @contributors, $person->get_name() . "($type)" );
}
}

# sort writer's names alphebetically by last name
@writers = sort by_lastname @writers;

# push writers onto front of contributor's array...
unshift( @contributors, @writers );

# build byline string
if( @contributors <= 0 ) {
$byline = "";
} else {
if( @contributors > 1 ) {
$byline = "by " . join( ", ", @contributors );
} else {
$byline = "by " . $contributors[0];
}
}

# set the byline var in the template
$template->param( byline => $byline );

-sam



_______________________________________________
Bricolage-General mailing list
Bricolage-General [at] lists
https://lists.sourceforge.net/lists/listinfo/bricolage-general

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.