<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I don't believe virtual fields will get searched because they aren't stored in the database.<div class=""><br class=""></div><div class="">You should add the multilang field to the search form, but I'm actually not sure how it will behave.</div><div class=""><br class=""></div><div class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">--</div><div class="">Adam Field</div><div class="">Business Relationship Manager and Community Lead<br class="">EPrints Services</div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 2 Jul 2015, at 12:10, George Mamalakis <<a href="mailto:mamalos@eng.auth.gr" class="">mamalos@eng.auth.gr</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
<div text="#000000" bgcolor="#FFFFFF" class="">
<div class="moz-cite-prefix">Excellent observation skills!!
:):)...and sorry for not having seen that.<br class="">
<br class="">
One more question. With this setup (for title and abstract with
two fields each), will searches work as expected? Meaning that,
based on the selected language, EPrints will search the
(dynamically generated) appropriate language title field for
example? Because I'm trying to test it, but I'm facing some
difficulties using the extended search menu, and I'm not sure if
this is the problem (putting the title ). Simple search works just
fine, but I assume that simple search searches all fields?<br class="">
<br class="">
Thanks again!<br class="">
<br class="">
George.<br class="">
<br class="">
On 02/07/2015 01:56 μμ, Adam Field wrote:<br class="">
</div>
<blockquote cite="mid:EMEW3|73a4001ecccee6365eaac02cd3bf5070r61BuP14eprints-tech-bounces|ecs.soton.ac.uk|23B38C80-5273-4408-AE6E-365233DA814D@ecs.soton.ac.uk" type="cite" class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
You need square brackets around the 0, not curly ones (you're
accessing an array, not a hash).
<div class=""><br class="">
<div class="">
<div class="">
<div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class="">--</div>
<div class="">Adam Field</div>
<div class="">Business Relationship Manager and Community
Lead<br class="">
EPrints Services</div>
</div>
</div>
<br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On 2 Jul 2015, at 11:52, George Mamalakis
<<a moz-do-not-send="true" href="mailto:mamalos@eng.auth.gr" class="">mamalos@eng.auth.gr</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">Hi Adam,<br class="">
<br class="">
I faced a problem when I performed the changes you
suggested, <br class="">
specifically with this line:<br class="">
<br class="">
${$$vals[0]}{'text'} becomes $vals->[0]->{text}<br class="">
<br class="">
After I changed this line, the program started to crash
(server error). <br class="">
When debugging it (by using a custom script that prints
the 'title''s <br class="">
value), when printing, for one of my records I received
a:<br class="">
<br class="">
Not a HASH reference at (eval 60) line 104.<br class="">
<br class="">
error. Line 104 was the line containing:<br class="">
<br class="">
$title = $vals->{0}->{'text'};<br class="">
<br class="">
Trying to see why this was happening, I realised that
the specific <br class="">
record was missing the lang value (where el should have
been present). <br class="">
Meaning:<br class="">
<br class="">
Previous value: $VAR1 = [<br class="">
{<br class="">
'text' => 'The English title',<br class="">
'lang' => 'en'<br class="">
},<br class="">
{<br class="">
'lang' => '',<br class="">
'text' => "\x{39f} <br class="">
\x{395}\x{3bb}\x{3bb}\x{3b7}\x{3bd}\x{3b9}\x{3ba}\x{3cc}\x{3c2}
<br class="">
\x{3c4}\x{3af}\x{3c4}\x{3bb}\x{3bf}\x{3c2}"<br class="">
}<br class="">
];<br class="">
<br class="">
How come my previous code was handling it without a
problem whereas the <br class="">
one you proposed weren't? As I said I'm not well
acquainted with perl, <br class="">
so I'm not even sure how to debug this any further. And,
to be honest, <br class="">
since missing values will definitely be a case for my
repository, I <br class="">
cannot adopt your suggestion once it breaks; but I
assume that there's <br class="">
an easy work-around for this.<br class="">
<br class="">
Thanks again!<br class="">
<br class="">
On 01/07/2015 05:14 μμ, Field A.N. wrote:<br class="">
<blockquote type="cite" class="">Hi George<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre">
</span>I wouldn't worry about performance unless
you're seeing specific problems. However, you can get
it from $repository->id() I believe. Don't assume
there's be a database lookup, as its<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre">
</span>I would also recommend the following changes in
syntax for readability:<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"> </span>%$v1{'lang'}
becomes $v1->{lang}<br class="">
<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"> </span>%$v1{'text'}
becomes $v1->{text}<br class="">
<span class="Apple-tab-span" style="white-space:pre">
</span><span class="Apple-tab-span" style="white-space:pre"> </span>${$$vals[0]}{'text'}
becomes $vals->[0]->{text}<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre">
</span>Best Wishes<br class="">
<br class="">
--<br class="">
Adam Field<br class="">
Business Relationship Manager and Community Lead<br class="">
EPrints Services<br class="">
+44 (0)23 8059 8814<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
On 1 Jul 2015, at 11:34, George Mamalakis wrote:<br class="">
<br class="">
<blockquote type="cite" class="">Cheers Adam,<br class="">
<br class="">
It worked like a charm! Now please allow me to
asking you one more<br class="">
thing: I changed my title field to contain code that
looks for my<br class="">
repository_id through the $eprint variable (which is
my method's<br class="">
parameter), which means that the system will have to
make an additional<br class="">
database call each time my field is accessed for
each object. There's no<br class="">
easier method of having access to it, I suppose?
(eg. directly, like I<br class="">
have access to the configuration via $c).<br class="">
<br class="">
PS. My new title-field code is as follows:<br class="">
<br class="">
{<br class="">
name => 'title',<br class="">
type => 'virtualwithvalue',<br class="">
virtual => 1,<br class="">
<br class="">
get_value => sub<br class="">
{<br class="">
my ($eprint) = @_;<br class="">
if ($eprint->is_set('ml_title'))<br class="">
{<br class="">
my $repo = $eprint->repository;<br class="">
my $lang = $repo->get_langid;<br class="">
# if cannot find a user language
setting, I'm taking the<br class="">
default one<br class="">
if (!$lang)<br class="">
{<br class="">
$lang = $c->{defaultlanguage};<br class="">
}<br class="">
my $vals =
$eprint->get_value('ml_title');<br class="">
my $title = '';<br class="">
# set the default lang's text as title<br class="">
foreach my $v1 (@{$vals})<br class="">
{<br class="">
if (%$v1{'lang'} eq $lang)<br class="">
{<br class="">
$title = %$v1{'text'};<br class="">
}<br class="">
}<br class="">
# if I couldn't find a title in the
user's language, get<br class="">
the first object's text as title<br class="">
if ($title eq '')<br class="">
{<br class="">
$title = ${$$vals[0]}{'text'} ;<br class="">
}<br class="">
return $title;<br class="">
<br class="">
}<br class="">
return undef;<br class="">
}<br class="">
},<br class="">
<br class="">
<br class="">
<br class="">
On 01/07/2015 12:30 μμ, Field A.N. wrote:<br class="">
<blockquote type="cite" class="">It should be:<br class="">
<br class="">
<span class="Apple-tab-span" style="white-space:pre"> </span>$repository->get_lang(),
which will return an EPrints::Language object, or
$repository->get_langid, which will return the
ID of the language.<br class="">
<br class="">
--<br class="">
Adam Field<br class="">
Business Relationship Manager and Community Lead<br class="">
EPrints Services<br class="">
+44 (0)23 8059 8814<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
On 30 Jun 2015, at 10:29, George Mamalakis wrote:<br class="">
<br class="">
<blockquote type="cite" class="">Hi all,<br class="">
<br class="">
I am testing the multilang field (with virtual
fields for title and<br class="">
abstract) and I am trying to make my virtual
field return a different<br class="">
title (or abstract) based on what the user's
language choice is. How can<br class="">
I have access to that variable on my perl
configuration file? (I've<br class="">
tested the default language and works as
expected, but I don't find it<br class="">
usable.)<br class="">
<br class="">
Thanks all in advance.<br class="">
<br class="">
-- <br class="">
George Mamalakis<br class="">
<br class="">
IT and Security Officer,<br class="">
Electrical and Computer Engineer (Aristotle
Univ. of Thessaloniki),<br class="">
PhD (Aristotle Univ. of Thessaloniki),<br class="">
MSc (Imperial College of London)<br class="">
<br class="">
School of Electrical and Computer Engineering<br class="">
Aristotle University of Thessaloniki<br class="">
<br class="">
phone number : +30 (2310) 994379<br class="">
<br class="">
<br class="">
*** Options: <a moz-do-not-send="true" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech" class="">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br class="">
*** Archive: <a moz-do-not-send="true" href="http://www.eprints.org/tech.php/" class="">http://www.eprints.org/tech.php/</a><br class="">
*** EPrints community wiki: <a moz-do-not-send="true" href="http://wiki.eprints.org/" class="">http://wiki.eprints.org/</a><br class="">
*** EPrints developers Forum: <a moz-do-not-send="true" href="http://forum.eprints.org/" class="">http://forum.eprints.org/</a><br class="">
</blockquote>
*** Options: <a moz-do-not-send="true" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech" class="">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br class="">
*** Archive: <a moz-do-not-send="true" href="http://www.eprints.org/tech.php/" class="">http://www.eprints.org/tech.php/</a><br class="">
*** EPrints community wiki: <a moz-do-not-send="true" href="http://wiki.eprints.org/" class="">http://wiki.eprints.org/</a><br class="">
*** EPrints developers Forum: <a moz-do-not-send="true" href="http://forum.eprints.org/" class="">http://forum.eprints.org/</a><br class="">
</blockquote>
<br class="">
-- <br class="">
George Mamalakis<br class="">
<br class="">
IT and Security Officer,<br class="">
Electrical and Computer Engineer (Aristotle Univ. of
Thessaloniki),<br class="">
PhD (Aristotle Univ. of Thessaloniki),<br class="">
MSc (Imperial College of London)<br class="">
<br class="">
School of Electrical and Computer Engineering<br class="">
Aristotle University of Thessaloniki<br class="">
<br class="">
phone number : +30 (2310) 994379<br class="">
<br class="">
<br class="">
<br class="">
*** Options: <a moz-do-not-send="true" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech" class="">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br class="">
*** Archive: <a moz-do-not-send="true" href="http://www.eprints.org/tech.php/" class="">http://www.eprints.org/tech.php/</a><br class="">
*** EPrints community wiki: <a moz-do-not-send="true" href="http://wiki.eprints.org/" class="">http://wiki.eprints.org/</a><br class="">
*** EPrints developers Forum: <a moz-do-not-send="true" href="http://forum.eprints.org/" class="">http://forum.eprints.org/</a><br class="">
</blockquote>
<br class="">
*** Options: <a moz-do-not-send="true" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech" class="">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br class="">
*** Archive: <a moz-do-not-send="true" href="http://www.eprints.org/tech.php/" class="">http://www.eprints.org/tech.php/</a><br class="">
*** EPrints community wiki: <a moz-do-not-send="true" href="http://wiki.eprints.org/" class="">http://wiki.eprints.org/</a><br class="">
*** EPrints developers Forum: <a moz-do-not-send="true" href="http://forum.eprints.org/" class="">http://forum.eprints.org/</a><br class="">
<br class="">
</blockquote>
<br class="">
<br class="">
-- <br class="">
George Mamalakis<br class="">
<br class="">
IT and Security Officer,<br class="">
Electrical and Computer Engineer (Aristotle Univ. of
Thessaloniki),<br class="">
PhD (Aristotle Univ. of Thessaloniki),<br class="">
MSc (Imperial College of London)<br class="">
<br class="">
School of Electrical and Computer Engineering<br class="">
Aristotle University of Thessaloniki<br class="">
<br class="">
phone number : +30 (2310) 994379<br class="">
<br class="">
<br class="">
<br class="">
*** Options: <a moz-do-not-send="true" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech" class="">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br class="">
*** Archive: <a moz-do-not-send="true" href="http://www.eprints.org/tech.php/" class="">http://www.eprints.org/tech.php/</a><br class="">
*** EPrints community wiki: <a moz-do-not-send="true" href="http://wiki.eprints.org/" class="">http://wiki.eprints.org/</a><br class="">
*** EPrints developers Forum: <a moz-do-not-send="true" href="http://forum.eprints.org/" class="">http://forum.eprints.org/</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<br class="">
<pre wrap="" class="">*** Options: <a class="moz-txt-link-freetext" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a>
*** Archive: <a class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>
</pre>
</blockquote>
<br class="">
<br class="">
<pre class="moz-signature" cols="72">--
George Mamalakis
IT and Security Officer,
Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
PhD (Aristotle Univ. of Thessaloniki),
MSc (Imperial College of London)
School of Electrical and Computer Engineering
Aristotle University of Thessaloniki
phone number : +30 (2310) 994379
</pre>
</div>
*** Options: <a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech" class="">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br class="">*** Archive: <a href="http://www.eprints.org/tech.php/" class="">http://www.eprints.org/tech.php/</a><br class="">*** EPrints community wiki: <a href="http://wiki.eprints.org/" class="">http://wiki.eprints.org/</a><br class="">*** EPrints developers Forum: <a href="http://forum.eprints.org/" class="">http://forum.eprints.org/</a><br class=""></div></blockquote></div><br class=""></div></body></html>