[index] [prev] [next] [options] [help]

eprints_tech messages

[EP-tech] Re: Author Browse View

From: Rory McNicholl <r.mcnicholl AT ulcc.ac.uk>
Date: Tue, 27 Sep 2011 17:23:22 +0100


Threading: [EP-tech] Re: Author Browse View from r.mcnicholl AT ulcc.ac.uk
      • This Message


On 26/09/11 16:44, Rory McNicholl wrote:
> Thanks Chris!
>
> I'll let you know how I get on with it, but it looks like just the 
> ticket :)


It was. Nice one.


>
> Rory
>
>
> On 21/09/11 10:04, C.S.Yates wrote:
>>
>> Hi Rory,
>>
>> Sorry, I think I missed that bit out in my original email. Here is 
>> the rest of it:
>>
>> cfg.d/view.pl
>>
>> {
>>
>>                 id => "person",
>>
>>                 allow_null => 0,
>>
>>                 hideempty => 0,
>>
>>                 menus => [
>>
>>                         {
>>
>>                                 fields => [ 
"creators_id", 
>> "editors_id" ],
>>
>>                                 new_column_at => [1, 1],
>>
>>                                 mode => "sections",
>>
>>                                 open_first_section => 1,
>>
>>                                 group_range_function => 
>> "EPrints::Update::Views::cluster_ranges_30",
>>
>>                                 grouping_function => 
"group_by_author",
>>
>>                         },
>>
>>                 ],
>>
>>                 citation => "neat",
>>
>>                 order => "creators_name/editors_name",
>>
>>                 variations => [
>>
>>                         "date;truncate=4,reverse",
>>
>>                         "type",
>>
>>                         "creators_name;first_letter",
>>
>>                         "DEFAULT",
>>
>>                 ],
>>
>>         },
>>
>> I've added two new functions group_by_author and alpha_first in a new 
>> .pl file; cfg.d/views_render_menu.pl (attached to this email and 
>> extension changed to txt). It's the group_by_author that's the 
>> required function, alpha first is a group_sorting_function for our 
>> journal browse view to ensure letters to appear before numbers.
>>
>> There is also a call to a function name_from_username in the 
>> group_by_author function. This basically gets the associated name of 
>> the user from their username:
>>
>> sub name_from_username
>>
>> {
>>
>>         my( $repo, $username ) =  AT _;
>>
>>         my $dataset = $repo->dataset( "user" );
>>
>>         my $results = $dataset->search(
>>
>>                 filters => [
>>
>>                         {
>>
>>                                 meta_fields => [qw( username )],
>>
>>                                 value => $username,
>>
>>                                 match => "EX"
>>
>>                         }
>>
>>                 ]);
>>
>>         my $user = $results->item( 0 );
>>
>>         return $user->{data}->{name};
>>
>> }
>>
>> I've actually used namespace overwriting to include this function 
>> into the EPrints::DataObj::User module as a plugin but you may want 
>> to place this function in views_render_menu.pl?
>>
>> If you restart apache and regenerate the author browse that should do 
>> it. There might be a better way to do this but it works for me!
>>
>> Let me know if it doesn't work and I'll double check I've not missed 
>> anything.
>>
>> Regards,
>>
>> Chris
>>
>> ---------------------------------------------------------
>>
>> Chris Yates
>>
>> Systems Librarian
>> Open University Library
>> Walton Hall
>> Milton Keynes
>> MK7 6AA
>>
>> Tel: +44(0)1908 858 796
>> Email: c.s.yates AT open.ac.uk <mailto:c.s.yates AT open.ac.uk>
>> Web: http://www.open.ac.uk <http://www.open.ac.uk/>
>> Twitter: http://www.twitter.com/chris_s_yates
>>
>> *From:*Rory McNicholl [mailto:r.mcnicholl AT ulcc.ac.uk]
>> *Sent:* 20 September 2011 18:13
>> *To:* eprints-tech AT ecs.soton.ac.uk
>> *Subject:* [EP-tech] Re: Author Browse View
>>
>> Hello Chris (and list),
>>
>> I've got a very similar requirement to Stephane and found that your 
>> solution worked nicely :)
>>
>> Except I notice that in your OU authors views the A-Z links at the 
>> top also correspond to names not IDs. As you can see my A-Z links are 
>> actually 1-9 links :(
>>
>> http://lshtmtest.da.ulcc.ac.uk/view/creators/
>>
>> Is there a bit more to the solution or have have I just done it wrong?
>>
>> Cheers,
>>
>> Rory
>>
>>
>> On 20/01/11 10:37, C.S.Yates wrote:
>>
>> Hi Stephane,
>>   
>> Is something like this what you're 
after:http://oro.open.ac.uk/view/person/?
>>   
>> We've had to create a new Metafield in 
[eprints]/perl_lib/EPrints/MetaField called Authorid.pm. In 
cfg.d/eprints_fields.pl our unique author identifier uses this as it's type 
i.e.:
>>   
>> {
>>              'name' =>  'creators',
>>              'type' =>  'compound',
>>              'multiple' =>  1,
>>              'fields' =>  [
>>                            {
>>                              'sub_name' =>  'name',
>>                              'type' =>  'name',
>>                              'hide_honourific' =>  1,
>>                              'hide_lineage' =>  1,
>>                              'family_first' =>  1,
>>                            },
>>                            {
>>                              'sub_name' =>  'id',
>>                              'type' =>  'authorid',
>>                              'input_cols' =>  20,
>>                              'allow_null' =>  1,
>>                            }
>>                          ],
>>              'input_boxes' =>  2,
>>            },
>>   
>> Authorid.pm is similar to Name.pm but only containing the following 
two functions to return the label as the author name instead of the id:
>>   
>> sub get_value_label
>> {
>>          my( $self, $session, $value ) =  AT _;
>>   
>>          my $user = EPrints::DataObj::User::user_with_username( 
$session, $value );
>>          if( defined $user )
>>          {
>>                  my $name = $user->get_value( "name" );
>>                  return $session->make_text( 
EPrints::Utils::make_name_string( $name ) );
>>          }
>>          return $session->make_text( $value );
>> }
>>   
>> sub ordervalue_basic
>> {
>>          my( $self, $value, $session, $langid ) =  AT _;
>>          my $user = EPrints::DataObj::User::user_with_username( 
$session, $value );
>>          if( defined $user )
>>          {
>>                  return EPrints::MetaField::Name::ordervalue_basic( 
$self, $user->get_value( "name" ) );
>>          }
>>          return $value;
>> }
>>   
>> Our view can still use creators_id, editors_id set as it's field. 
There might be an better/easier way to do this, but it works for us. I hope 
this makes sense,
>>   
>> Cheers,
>> Chris
>>   
>> ---------------------------------------------------------
>> Chris Yates
>> Programmer/Repository Web Developer
>> Open University Library
>> Walton Hall
>> Milton Keynes
>> MK7 6AA
>>   
>> Tel: +44(0)1908 858 796
>> Email:c.s.yates AT open.ac.uk  <mailto:c.s.yates AT open.ac.uk>
>> Web:http://oro.open.ac.uk
>> Blog:http://www.open.ac.uk/blogs/ORO
>> Twitter:http://www.twitter.com/chris_s_yates
>>   
>>   
>> -----Original Message-----
>> From: Stephane Sechaud [mailto:stephane.sechaud AT strath.ac.uk]
>> Sent: 20 January 2011 09:55
>> To: 'eprints-tech AT ecs.soton.ac.uk  <mailto:eprints-tech AT 
ecs.soton.ac.uk>'
>> Subject: [EP-tech] Author Browse View
>>   
>> Hi everyone,
>>   
>> I am trying to get a browse view for authors to generate the menu 
against our authors unique identifier field "eprint_creators_uid" 
while showing the name in the top level browse view menu. This way we get a 
list of the names, but the pages are named against the unique ID. This unique 
ID is getting set from Pure when we are importing our records from there.
>>   
>> I have read through the documentation online 
here:http://wiki.eprints.org/w/Views.pl#Menu_options
>>   
>> However I can only get it to make the menu of unique Id's. Here is 
what I have in "views.pl":
>>   
>> ####
>> #Unique Authors
>> { id =>  "unique-authors",
>>    menus =>  [ { fields =>  ["creators_uid"],
>>      new_column_at =>  [1,1],
>>      mode =>  "sections",
>>       open_first_section =>  1,
>>      group_range_function =>  
"EPrints::Update::Views::cluster_ranges_30",
>>      grouping_function =>  
"EPrints::Update::Views::group_by_a_to_z", }, ],
>>      new_column_at =>  [0,0],
>>      variations =>  [ "date;truncate=4,reverse",
>>        "type",
>>        "keywords;tags;cloud",
>>        "DEFAULT" ],
>>      Order =>  "-date/title",
>> ],
>> ####
>>   
>> Would anyone know where I am going wrong? Should I be making a new 
"views_render_menu.pl"? Or do I need to stick something like 
"res=" or "render_" in the field menu definition? Any 
advice would be greatly appreciated.
>>   
>> Thanks,
>>   
>> Stephane Sechaud
>> ERIS Project Assistant
>> University of Strathclyde
>> Room 3.02
>> Alexander Turnbull Building
>> 165 George Street
>> Glasgow
>> G1 1RD
>> Phone: +44 (0)141 548 2379
>> Web:http://www.strath.ac.uk/cdlr
>> The University of Strathclyde is a charitable body, registered in 
Scotland, with registration number SC015263.
>>   
>>   
>> *** 
Options:http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
>> *** Archive:http://www.eprints.org/tech.php/
>> *** EPrints community wiki:http://wiki.eprints.org/
>>   
>>
>> -- 
>>
>> Rory McNicholl
>> Technical Manager
>> Digital Archives & Repositories Team
>> University of London Computer Centre
>> Senate House
>> Malet Street
>> London
>> WC1E 7HU
>>
>> t: +44 (0)20 7863 1344
>> e: r.mcnicholl AT ulcc.ac.uk <mailto:r.mcnicholl AT ulcc.ac.uk>
>> w: http://www.ulcc.ac.uk/
>> b: http://dablog.ulcc.ac.uk/
>>
>> The University of London is an exempt charity in England and Wales 
>> and a charity registered in Scotland (reg. no. SC041194)
>>
>>
>> -- 
>> The Open University is incorporated by Royal Charter (RC 000391), an 
>> exempt charity in England & Wales and a charity registered in 
>> Scotland (SC 038302).
>>
>>
>> *** 
Options:http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
>> *** Archive:http://www.eprints.org/tech.php/
>> *** EPrints community wiki:http://wiki.eprints.org/
>
>
> -- 
> Rory McNicholl
> Technical Manager
> Digital Archives & Repositories Team
> University of London Computer Centre
> Senate House
> Malet Street
> London
> WC1E 7HU
>
> t: +44 (0)20 7863 1344
> e: r.mcnicholl AT ulcc.ac.uk
> w: http://www.ulcc.ac.uk/
> b: http://dablog.ulcc.ac.uk/
>
> The University of London is an exempt charity in England and Wales and 
> a charity registered in Scotland (reg. no. SC041194)
>
>
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/


-- 
Rory McNicholl
Technical Manager
Digital Archives & Repositories Team
University of London Computer Centre
Senate House
Malet Street
London
WC1E 7HU

t: +44 (0)20 7863 1344
e: r.mcnicholl AT ulcc.ac.uk
w: http://www.ulcc.ac.uk/
b: http://dablog.ulcc.ac.uk/

The University of London is an exempt charity in England and Wales and a 
charity registered in Scotland (reg. no. SC041194)


ATTACHMENT: message.html!

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech *** Archive: http://www.eprints.org/tech.php/ *** EPrints community wiki: http://wiki.eprints.org/

[index] [prev] [next] [options] [help]