Re: [EP-underground] Questions about subjects

Alan Schmitz <[email protected]> Sun, 26 Jan 2003 16:15:09 -0600
Newsgroups gmane.comp.web.eprints.general
Message-ID <[email protected]>
A couple of months ago I asked a question about subject keyword 
searches in E-Prints.  Chris Gutteridge responded with the field 
definitions and code below.  I'm finally getting around to implementing 
his suggestion which includes using a new text field for subject 
keywords.

The code works until it tries to call the "render_description" 
function.  Perl gives the following error, 'Can't call method 
"render_description" on unblessed reference'.

I've also tried to make a new subject object from the subject ID, but I 
don't know what I'm supposed to pass for the session parameter.  What 
do I need to do so I can call "render_description", or how do I make a 
new subject object from a subject ID?

Thanks,
Alan Schmitz

----
SILO Project Coordinator
State Library of Iowa

> { name => "searchsubjects", type=>"subject", top=>"subjects", multiple 
> => 1, browse_link => "subjects" },
>
> { name => "subjectstext", type => "longtext" },
>
> we'd make the following trigger
>
> sub set_eprint_automatic_fields
> {
> 	my( $eprint ) = @_;
> 	my $searchsubjects = [];
> 	my $setall = 0;
> 	foreach my $subjid ( $eprint->get_value( "subjects" ) )
> 	{
> 		push @{$searchsubjects}, $subjid;
> 		if( $subjid eq "all" ) # or whatever the key for the ALL field is
> 		{
> 			$setall = 1;
> 		}
> 	}
>
> 	# set ALL the searchsubjects if the flag is set
> 	if( $setall )
> 	{
> 		foreach my $subjid (
> 			"dallas",
> 			"foo",
> 			"baz",
> 			"fnord",
> 			"bar" )
> 		{
> 			push @{$searchsubjects}, $subjid;
> 		}
> 	}
>
> 	$eprint->set_value( "searchsubjects", $searchsubjects );
>
> 	my $stext = "";
> 	foreach my $subj ( @{$searchsubjects} )
> 	{
> 		$stext .= EPrints::Utils::tree_to_utf8(
> 				$subj->render_description )." ";
> 	}
> 	$eprint->set_value( "subjectstext", $stext );
> }