<HTML><BODY>
    <br />
   <br />
    Thanks John, that was exactly what I was looking for, I&rsquo;ve had a bad<BR>
experience installing plugins before (entirely my fault) and am therefore<BR>
reluctant to do it again and yes we only run a single repository.<BR>
<BR>
Kind Regards<BR>
Derek<BR>
<BR>
<BR>
Derek Lawrie<BR>
Web Developer and Administrator<BR>
T: 01603 751498 | Ext: 6498<BR>
w: <a href="http://www.nua.ac.uk" target="_blank">www.nua.ac.uk</a> &lt;://www.nua.ac.uk&gt; <BR>
<BR>
<BR>
<BR>
Norwich University of the Arts, Francis House, 3-7 Redwell Street,<BR>
Norwich, NR2 4SN<BR>
<BR>
<BR>
<BR>
<BR>
From:  John Salter &lt;<a href="mailto:J.Salter@leeds.ac.uk">J.Salter@leeds.ac.uk</a>&gt; <BR>
Reply-To:  Eprints &lt;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&gt; <BR>
Date:  Thursday, February 6, 2014 at 3:18 PM<BR>
To:  Eprints &lt;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&gt; <BR>
Subject:  [EP-tech] Re: Random selection<BR>
<BR>
<BR>
You should be able to achieve it without using Kultur itself &shy; but the<BR>
functions in there will provide a good place to start.<BR>
 <BR>
This is what I&rsquo;d do:<BR>
1.      <BR>
Make a file ~/archives/ARCHIVEID/cfg/cfg.d/z_random_selection.pl<BR>
2.      <BR>
In that file, add something like the stuff below (which is based on the<BR>
Kultur stuff). As you&rsquo;re writing into the global packages, it&rsquo;s sensible to<BR>
 include the archiveid in the function names for clarity (if you only run<BR>
one archive, this might not matter to you).<BR>
3.      <BR>
Add something like:<BR>
&lt;div&gt;&lt;epc:print expr=&quot;ARCHIVEID_render_random_eprints(10)&quot; /&gt;&lt;/div&gt;<BR>
                to ~/archives/ARCHIVEID/cfg/lang/en/static/index.xpage<BR>
4.      <BR>
run ~/bin/epadmin test ARCHIVEID (cross fingers first)<BR>
5.      <BR>
Restart Apache, go to your homepage, have a pint of beer :o)<BR>
 <BR>
You might want to tweak the mysql bit to taste &shy; but this should get you<BR>
started&hellip;<BR>
Cheers,<BR>
John<BR>
 <BR>
#####################################################################<BR>
#  Add things to the EPrints::Script::Compiled package so you can use them<BR>
from epscript #<BR>
#####################################################################<BR>
 <BR>
{<BR>
package EPrints::Script::Compiled;<BR>
 <BR>
use strict;<BR>
 <BR>
sub run_ARCHIVEID_render_random_eprints<BR>
{<BR>
        my( $self, $state, $max ) = @_;<BR>
 <BR>
        if( $max-&gt;[1] ne &quot;INTEGER&quot; )<BR>
        {<BR>
                EPrints::abort( &quot;Usage: ARCHIVEID_render_random_eprints(<BR>
MAX )&quot; );<BR>
        }<BR>
 <BR>
        $max = $max-&gt;[0];<BR>
 <BR>
        my $session = $state-&gt;{session};<BR>
 <BR>
        my $eprints = _ARCHIVEID_random_eprints( $session, $max );<BR>
 <BR>
        my $frag = $session-&gt;make_doc_fragment;<BR>
 <BR>
                                #render your items how you want them<BR>
        my $div = $session-&gt;make_element( &quot;div&quot;, id =&gt; &quot;random_eprints&quot; );<BR>
        $frag-&gt;appendChild( $div );<BR>
 <BR>
        foreach my $eprint (@$eprints)<BR>
        {<BR>
                                                #render your items how you<BR>
want them<BR>
                                                my $citation =<BR>
$eprint-&gt;render_citation_link( &quot;default&quot; );<BR>
            $div-&gt;appendChild( $citation );<BR>
        }<BR>
 <BR>
        return [ $frag, &quot;XHTML&quot; ];<BR>
}<BR>
 <BR>
sub _ARCHIVEID_random_eprints<BR>
{<BR>
        my( $session, $max ) = @_;<BR>
 <BR>
        my $eprints = [];<BR>
 <BR>
        my $ids = _ARCHIVEID_mysql_rand_eprints( $session, $max*10 );<BR>
 <BR>
        for(@$ids)<BR>
        {<BR>
                my( $eprintid ) = @$_;<BR>
 <BR>
                my $eprint = EPrints::DataObj::EPrint-&gt;new( $session,<BR>
$eprintid );<BR>
                next unless defined $eprint;<BR>
 <BR>
                push @$eprints, $eprint;<BR>
                last if --$max == 0;<BR>
        }<BR>
 <BR>
        return $eprints;<BR>
}<BR>
 <BR>
sub _ARCHIVEID_mysql_rand_eprints<BR>
{<BR>
        my( $session, $max ) = @_;<BR>
 <BR>
        my @ids;<BR>
 <BR>
        my $sql = &quot;SELECT eprintid FROM eprint WHERE<BR>
eprint_status='archive' AND full_text_status = 'public'&quot;;<BR>
 <BR>
        $sql .= &quot; ORDER BY RAND() LIMIT $max&quot;;<BR>
 <BR>
        my $sth = $session-&gt;get_database-&gt;prepare( $sql );<BR>
        $sth-&gt;execute;<BR>
 <BR>
        while(my @row = $sth-&gt;fetchrow_array)<BR>
        {<BR>
                push @ids, \@row;<BR>
        }<BR>
 <BR>
        return \@ids;<BR>
}<BR>
 <BR>
#####################################################################<BR>
# END<BR>
#####################################################################<BR>
 <BR>
 <BR>
 <BR>
From: <a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> <BR>
[mailto:eprints-tech-bounces@ecs.soton.ac.uk]<BR>
On Behalf Of Derek Lawrie<BR>
Sent: 06 February 2014 13:36<BR>
To: <a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a> <BR>
Subject: [EP-tech] Re: Random selection<BR>
<BR>
<BR>
 <BR>
<BR>
<BR>
Hi John, I was pointed in the direction of Kultur plugin when I was first<BR>
asked to do the repository, at that time I found (with lots of help on<BR>
here from you and others) that I could do everything I wanted without<BR>
installing kultur, so I&rsquo;d quite like to try and keep it out of the picture.<BR>
<BR>
If it isn&rsquo;t possible without using Kultur then that&rsquo;s fine, was just<BR>
hoping that it was!<BR>
<BR>
Thanks<BR>
Derek<BR>
<BR>
<BR>
<BR>
From: John Salter &lt;<a href="mailto:J.Salter@leeds.ac.uk">J.Salter@leeds.ac.uk</a>&gt; <BR>
<BR>
Reply-To: Eprints &lt;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&gt; <BR>
<BR>
Date: Thursday, February 6, 2014 at 10:01 AM<BR>
To: Eprints &lt;<a href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a>&gt; <BR>
<BR>
Subject: [EP-tech] Re: Random selection<BR>
<BR>
<BR>
You might want to look at the &lsquo;Kultur&rsquo; extension<BR>
<a href="http://files.eprints.org/773/" target="_blank">http://files.eprints.org/773/</a> &shy; specifically the &lsquo;slideshow&rsquo; part of the <BR>
<BR>
code that produces a random selection of items.<BR>
Look at perl_lib/EPrints/Script/Kultur.pm &shy; that writes stuff into the<BR>
EPrints::Script::Compiled package.<BR>
<BR>
**this is a very good example of what to do if you want to extend epscript<BR>
to do something fancy!**<BR>
<BR>
- You can then edit your index.xpage to include:<BR>
<BR>
&lt;epc:print expr=&quot;kultur_slideshow(10)&quot; /&gt;<BR>
to render a 10-image slideshow.<BR>
<BR>
The logic in the slideshow could also be used as a basis for random<BR>
selection in e.g. an RSS feed.<BR>
<BR>
Hope that helps!<BR>
John<BR>
<BR>
From: <a href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a> <BR>
[mailto:eprints-tech-bounces@ecs.soton.ac.uk]<BR>
On Behalf Of Derek Lawrie<BR>
Sent: 06 February 2014 09:36<BR>
To: Eprints<BR>
Subject: [EP-tech] Random selection<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
Hi all,<BR>
I&sup1;ve not needed to tinker with our repository for a couple of months, but<BR>
have just been asked if I change the front page &sup3;latest items&sup2; to a random<BR>
selection temporarily, as there isn&sup1;t enough new stuff being uploaded<BR>
currently and it looks a bit odd.<BR>
<BR>
Is that an easy change to make? Like I say it&sup1;s only temporary so I will<BR>
want to keep the current code ready for when they ask to change it back.<BR>
<BR>
Would I be able to do it in latest_tool.pl ?<BR>
<BR>
Thanks<BR>
Derek<BR>
<BR>
Derek Lawrie<BR>
Web Developer and Administrator<BR>
T: 01603 751498 | Ext: 6498<BR>
w: <a href="http://www.nua.ac.uk" target="_blank">www.nua.ac.uk</a> &lt;<a href="http://www.nua.ac.uk" target="_blank">http://www.nua.ac.uk</a>&gt; &lt;<a href="http://www.nua.ac.uk" target="_blank">http://www.nua.ac.uk</a>&gt; <BR>
&lt;://www.nua.ac.uk&gt;<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
Norwich University of the Arts, Francis House, 3-7 Redwell Street,<BR>
Norwich, NR2 4SN<BR>
<BR>
Rated top Specialist Arts Institution in the UK (National Student Survey<BR>
2013) and best Specialist Institution in Art and Design (Complete<BR>
University Guide 2014)<BR>
<BR>
Internet communications cannot be guaranteed to be secure or error-free as<BR>
information could be intercepted, corrupted, lost, destroyed, arrive late<BR>
or incomplete, or contain viruses.<BR>
Therefore, we do not accept responsibility for any errors or omissions<BR>
that are present in this message, or any attachment, that have arisen as a<BR>
result of e-mail transmission. If verification is required, please request<BR>
a hard-copy version. Any views or opinions<BR>
presented are solely those of the author and do not necessarily represent<BR>
those of the University.<BR>
<BR>
<BR>
This email and any files sent with it are intended only for the named<BR>
recipient and may be confidential. If you are not the named recipient<BR>
please email the sender immediately then delete this message. You should<BR>
not disclose the content, distribute or retain<BR>
any copies of this message.<BR>
<BR>
<BR>
Norwich University of the Arts,<BR>
Francis House,<BR>
3-7 Redwell Street,<BR>
Norwich, NR2 4SN.<BR>
Tel: 01603 610561<BR>
Fax: 01603 615728<BR>
<a href="http://www.nua.ac.uk" target="_blank">www.nua.ac.uk</a> &lt;<a href="http://www.nua.ac.uk" target="_blank">http://www.nua.ac.uk</a>&gt; &lt;<a href="http://www.nua.ac.uk" target="_blank">http://www.nua.ac.uk</a>&gt; <BR>
<BR>
<BR>
NUA Business Limited<BR>
Registered office:<BR>
Francis House,<BR>
3-7 Redwell Street,<BR>
Norwich, NR2 4SN.<BR>
Registered in England &amp; Wales number 3001912<BR>
<BR>
Rated top Specialist Arts Institution in the UK (National Student Survey<BR>
2013) and best Specialist Institution in Art and Design (Complete<BR>
University Guide 2014)<BR>
<BR>
Internet communications cannot be guaranteed to be secure or error-free as<BR>
information could be intercepted, corrupted, lost, destroyed, arrive late<BR>
or incomplete, or contain viruses.<BR>
 Therefore, we do not accept responsibility for any errors or omissions<BR>
that are present in this message, or any attachment, that have arisen as a<BR>
result of e-mail transmission. If verification is required, please request<BR>
a hard-copy version. Any views or opinions<BR>
 presented are solely those of the author and do not necessarily represent<BR>
those of the University.<BR>
<BR>
<BR>
This email and any files sent with it are intended only for the named<BR>
recipient and may be confidential. If you are not the named recipient<BR>
please email the sender immediately then delete this message. You should<BR>
not disclose the content, distribute or retain<BR>
 any copies of this message.<BR>
<BR>
<BR>
Norwich University of the Arts,<BR>
Francis House,<BR>
3-7 Redwell Street,<BR>
Norwich, NR2 4SN.<BR>
Tel: 01603 610561<BR>
Fax: 01603 615728<BR>
<a href="http://www.nua.ac.uk" target="_blank">www.nua.ac.uk</a> &lt;<a href="http://www.nua.ac.uk" target="_blank">http://www.nua.ac.uk</a>&gt; <BR>
<BR>
NUA Business Limited<BR>
Registered office:<BR>
Francis House,<BR>
3-7 Redwell Street,<BR>
Norwich, NR2 4SN.<BR>
Registered in England &amp; Wales number 3001912<BR>

    <br />      <span style="font-size:11.0pt; font-family:&quot;Arial&quot;,&quot;sans-serif&quot;; color:#0000cc; font-weight:bold">
      Rated top Specialist Arts Institution in the UK (National Student Survey 2013) and best Specialist Institution in Art and Design (Complete University Guide 2014)</span>
     <br /><br />
<font color="black" size="1" face="Verdana, Arial, Helvetica, sans-serif">
Internet communications cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. Therefore, we do not accept responsibility for any errors or omissions that
are present in this message, or any attachment, that have arisen as a result of e-mail transmission. If verification is required, please
request a hard-copy version. Any views or opinions presented are solely those of the author and do not necessarily represent
those of the University.
<br /><br />
This email and any files sent with it are intended only for the named recipient and may be confidential. If you are not the named 
recipient please email the sender immediately then delete this message. You should not disclose the content, distribute or retain
any copies of this message.
<br /><br /><br />
Norwich University of the Arts, <br />Francis House,<br />3-7 Redwell Street, <br />Norwich, NR2 4SN.<br />  
Tel: 01603 610561<br />
Fax: 01603 615728<br />
<a href="http://www.nua.ac.uk" target="_blank">www.nua.ac.uk</a><br />
<br />
NUA Business Limited<br />
Registered office:<br />
Francis House,<br />
3-7 Redwell Street,<br /> 
Norwich, NR2 4SN.<br />
Registered in England &amp; Wales number 3001912<br />
</font>
<br />
<span>
</span></BODY></HTML>