Linked LCSH Subjects from Pawtucket Object page

Hello,

I've added LCSH subjects to my object detail page (frontend) but can't get the linking to work correctly. Currently, when I click on a subject, it seems to search on the LC URI with character issues:

Example URL: index.php/Browse/objects/facet/lcsh_facet/id/Philosophy%2B%255Binfo%253Alc%252Fauthorities%252Fsubjects%252Fsh85100849%255D

As a facet in the Object filters, the same term works perfectly:

Example URL: index.php/Browse/objects/key/ecc7411b22d8481e480b6140ebe83778/facet/lcsh_facet/id/68488/view/images

Do you have a suggestion for how this might be fixed? This is my code:


<?php

$va_lcshTopical = $t_object->get("ca_objects.lcshTopical", array("returnAsArray" => true));

  if(sizeof($va_lcshTopical)){

  $va_terms = array();

  foreach($va_lcshTopical as $vs_lcshTopical){

  $vn_chop = stripos($vs_lcshTopical, "[");

  $va_terms[] = caNavLink($this->request, ($vn_chop) ? substr($vs_lcshTopical, 0, $vn_chop) : $vs_lcshTopical, "", "", "Browse", "objects", array("facet" => "lcsh_facet", "id" => urlencode($vs_lcshTopical)));

  }

  print "<div class='unit'><H6>Library of Congress Subjects".((sizeof($va_terms) > 1) ? "s" : "")."</H6>".join($va_terms, ", ")."</div>";

  }

?>


Thank you.

Comments

  • This worked for me:

    <?php

    $va_all_subjects = array();

    foreach(array("lcshNames", "lcshTopical", "lcshGeo") as $vs_field){

    $va_lc = $t_object->get("ca_objects.".$vs_field, array("returnAsArray" => true));

    $va_lc_names_processed = array();

    if(is_array($va_lc) && sizeof($va_lc)){

    foreach($va_lc as $vs_lc_terms){

    if($vs_lc_terms){

    $vs_lc_term = "";

    if($vs_lc_terms && (strpos($vs_lc_terms, " [") !== false)){

    $vs_lc_term = mb_substr($vs_lc_terms, 0, strpos($vs_lc_terms, " ["));

    }

    $va_all_subjects[] = caNavLink($this->request, $vs_lc_term, "", "", "Search", "objects", array("search" => "ca_objects.".$vs_field.": ".$vs_lc_term));

    }

    }

    }

    }

    if(is_array($va_all_subjects) && sizeof($va_all_subjects)){

    print "<div class='unit'><label>Subjects</label>".join(", ", $va_all_subjects)."</div>";

    }

    ?>

Sign In or Register to comment.