Browse Source

fixed issue with random titles and abstracts not returning 10 items

main
Simon Bowie 2 years ago
parent
commit
7a4bedb650
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      site/solr.php

+ 8
- 3
site/solr.php View File

@@ -162,13 +162,15 @@ function one_random_record ($core){

function ten_random_titles ($core){

for ($x=0; $x <= 9; $x++) {
$x = 0;
while ($x <= 9) {
$random = get_random_record($core);

foreach($random as $id => $content){
// Search for the title in the content element and display it
if (preg_match('/Title.*\n(.*)\n/', $content, $title)){
$output[$x] = array($id=>$title[1]);
++$x;
}
}
}
@@ -177,16 +179,19 @@ function ten_random_titles ($core){

function ten_random_abstracts ($core){

for ($x=0; $x <= 9; $x++) {
$x = 0;
while ($x <= 9) {
$random = get_random_record($core);

foreach($random as $id => $content){
// Search for the abstract in the content element and display it
if (preg_match('/Abstract.*\n(.*)\n/', $content, $abstract)){
$output[$x] = array($id=>$abstract[1]);
++$x;
}
elseif (preg_match('/\(.\) \\n\\n(.*)\\n/', $content, $abstract)) {
$output[$x] = array($id=>$abstract[1]);
++$x;
}
}
}
@@ -196,7 +201,7 @@ function ten_random_abstracts ($core){
function ten_random_doc_refs ($core){

$x = 0;
while ($x < 9) {
while ($x <= 9) {
$random = get_random_record($core);

foreach($random as $id => $content){

Loading…
Cancel
Save