Re: [EP-underground] Questions about subjects

ePrints Support <[email protected]> Mon, 10 Feb 2003 12:35:52 +0000
Newsgroups gmane.comp.web.eprints.general
Message-ID <[email protected]>
oh, my bad!

The $subj is an id string, not a subject object

change:

	foreach my $subj ( @{$searchsubjects} )
	{
		$stext .= EPrints::Utils::tree_to_utf8(
				$subj->render_description )." ";
	}
to
	foreach my $subj_id ( @{$searchsubjects} )
	{
		my $subj = EPrints::Subject->new( $session, $subj_id );
		$stext .= EPrints::Utils::tree_to_utf8(
				$subj->render_description )." ";
	}

On Sun, Jan 26, 2003 at 04:15:09 -0600, Alan Schmitz wrote:
> 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 );
> > }

-- 

 Christopher Gutteridge                   [email protected]
 ePrints2 Coder, Support and Stuff        +44 23 8059 4833