From b5b5241c6f84f11301f611187c2a32d99c331973 Mon Sep 17 00:00:00 2001 From: Daniel Messer Date: Mon, 7 Aug 2023 21:30:16 -0500 Subject: [PATCH] Clickable subjects. --- TODO.md | 4 ++-- itemrecord.php | 3 ++- results.php | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 8d150ec..a921260 100644 --- a/TODO.md +++ b/TODO.md @@ -9,10 +9,10 @@ In no particular order, here is a semi-current list of things to be done in Info [ ] Add a citation generator (Chicago, APA, MLA) -[ ] Item pages - Add clickable links on Subjects - [ ] Add share button/link on item page +[x] Item pages - Add clickable links on Subjects + [x] Item pages - Add clickable links on Series [x] Menu - change categories to media types and hook to latest list diff --git a/itemrecord.php b/itemrecord.php index 7252b67..4176127 100644 --- a/itemrecord.php +++ b/itemrecord.php @@ -251,7 +251,8 @@ while ($row = $series->fetchArray()) { echo 'Subjects: '; while ($row = $tags->fetchArray()) { $row_tags = $row['name']; - echo '['.$row_tags.'] '; + //echo '['.$row_tags.'] '; + echo '['.$row_tags.']'; } echo '
Identifiers:
'; while ($row = $identifiers->fetchArray()) { diff --git a/results.php b/results.php index cb3fe11..d6f88e2 100644 --- a/results.php +++ b/results.php @@ -7,11 +7,13 @@ $keywordsearch = htmlspecialchars($_GET["kw"]); $authorsearch = htmlspecialchars($_GET["au"]); $typesearch = htmlspecialchars($_GET["ty"]); $seriessearch = htmlspecialchars($_GET["se"]); +$subjectsearch = htmlspecialchars($_GET["su"]); $socialkw = mb_convert_case($keywordsearch, MB_CASE_TITLE, "UTF-8"); $socialau = mb_convert_case($authorsearch, MB_CASE_TITLE, "UTF-8"); $socialty = mb_convert_case($typesearch, MB_CASE_TITLE, "UTF-8"); $socialse = mb_convert_case($seriessearch, MB_CASE_TITLE, "UTF-8"); +$socialsu = mb_convert_case($subjectsearch, MB_CASE_TITLE, "UTF-8"); if (!empty($keywordsearch)) { $searchtopic = 'Keyword: '.$socialkw; @@ -19,8 +21,10 @@ if (!empty($keywordsearch)) { $searchtopic = 'Author: '.$socialau; } elseif (!empty($typesearch)) { $searchtopic = 'Type: '.$socialty; -} else { +} elseif (!empty($seriessearch)) { $searchtopic = 'Series: '.$socialse; +} else { + $searchtopic = 'Subject: '.$socialsu; } // -------------------- BEGIN DATABASE QUERIES -------------------- @@ -86,6 +90,20 @@ series ON series.id = books_series_link.series WHERE series.name = '$seriessearch' ORDER BY books.series_index ASC"); +$subjectquery = $db->query("SELECT +DISTINCT books.id AS id, +books.title AS title, +SUBSTR(comments.text,0,120) AS excerpt +FROM books +INNER JOIN +comments ON comments.book = books.id +INNER JOIN +books_tags_link on books_tags_link.book = books.id +INNER JOIN +tags on tags.id = books_tags_link.tag +WHERE tags.name = '$subjectsearch' +ORDER BY books.title ASC"); + $types = $db->query("SELECT value FROM custom_column_1 @@ -137,9 +155,12 @@ ORDER BY value ASC"); } elseif (!empty($typesearch)) { echo ''; echo ''; - } else { + } elseif (!empty($seriessearch)) { echo ''; echo ''; + } else { + echo ''; + echo ''; } ?> @@ -279,12 +300,20 @@ ORDER BY value ASC"); echo '

'.$row_title.' : '.strip_tags($row_excerpt).'...

'; } - } else { + } elseif ($seriessearch != '') { while ($row = $seriesquery->fetchArray()) { $row_id = $row['id']; $row_title = $row['title']; $row_excerpt = $row['excerpt']; + echo '

'.$row_title.' : '.strip_tags($row_excerpt).'...

'; + } + } else { + while ($row = $subjectquery->fetchArray()) { + $row_id = $row['id']; + $row_title = $row['title']; + $row_excerpt = $row['excerpt']; + echo '

'.$row_title.' : '.strip_tags($row_excerpt).'...

'; } }