Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the CollectiveAccess support forum! Here the developers and community answer questions related to use of the software. Please include the following information in every new issue posted here:

  1. Version of the software that is used, along with browser and version

  2. If the issue pertains to Providence, Pawtucket or both

  3. What steps you’ve taken to try to resolve the issue

  4. Screenshots demonstrating the issue

  5. The relevant sections of your installation profile or configuration including the codes and settings defined for your local elements.

If your question pertains to data import or export, please also include:

  1. Data sample

  2. Your mapping

Answers may be delayed for posts that do not include sufficient information.

Display Templates links to related terms

edited November 2016 in Pawtucket

I’ve got a question related to Display Templates and Pawtucket2 that I can’t find an answer to. I’m modifying the ca_objects_default_html.php file in the themes/views directory with some success. Now, we have definded a Metadata filed called "Schlagworte" (Keywords) which is based on a vocabularylist called "schlagwort_liste". 

When I’m using this code, the related terms show up on a object detail page:

{{{<ifdef code="ca_objects.schlagworte"><H5>Schlagworte:</H5><unit relativeTo="ca_objects" delimiter="<br/>"><l>^ca_objects.schlagworte</l></unit><HR></ifdef>}}}

The Problem is that the individual keyords show up, but they just link to the related object which kind of makes no sense because the link points to the very same page. So, clicking on a keyword does nothing, but I want it to show all objects which are related to the keyword, just like when you browse for one of the keywords.

If I understand it correctly, the "unit relativeTo" part defines to which kind of authority the link is related. But I had no luck trying relativeTo="ca_list_items.schlagwort_liste" or anything really. How is this to be done?

Thanks for your help!

Btw we’re running Providence 1.6.3 master branch and Pawtucket2 master branch pulled yesterday. Everything is set to be public accessible and the keywords are browseable.


  • Okay so I figured out that Terms have to be added as related terms using a relationship type restriction. They are showing fine now and the link generated does not point to the object any more. But it does not work either:

    It points to "/index.php/Detail//name_of_term" please see the empty slashes inbetween: normally (for examples with places) the link would be "/index.php/Detail/places/name_of_place". It seems as if there is no detailpage for terms - is it possible to add one? I searched all themes provided on github but didn’t find anything. 

    I’m curious if what I try to archive is possible with CA. I think it would be great to be able to click on a keyword related to an object and then see all other objects linked to the keyword.

    Thanks for your help!

  • Figured this out as well, perhaps its helping someone else:

    • In your themes detail.conf add the option to browse terms:
    terms = {
    displayName = _(Vokabulare),
    table = ca_list_items,
    restrictToTypes = [],
    options = {
    nextLink = <i class='fa fa-angle-right'></i><div class='small'>Next</div>,
    previousLink = <i class='fa fa-angle-left'></i><div class='small'>Prev</div>,
    resultsLink = <i class='fa fa-angle-double-left'></i><div class='small'>Back</div>,
    enableComments = 0,
    enableShare = 0,

    • In your themes Views-Detail create a new file ca_list_items_default_html.php (make a duplicate from another detail view) and customize it to show whatever you need. Most importantly (in my case) was to add support for multiple related objects:
    {{{<ifcount code="ca_objects" min="1" max="1"><HR><H4>Related Object</H4><unit relativeTo="ca_objects" delimiter=" "><l>^</l><br/><l>^</l><br/></unit></ifcount>}}}

    {{{<ifcount code="ca_objects" min="2"><HR><H4>Related Objects</H4><unit relativeTo="ca_objects" delimiter=" "><l>^</l><br/><l>^</l><br/></unit></ifcount>}}}
  • I'm trying to do something very similar for our site, and the directions you've left here are extremely helpful!  Thanks!  The one part that's still giving me some trouble is the code for the ca_objects_default_html.php file.  When you say that you added the element as a related term, did you add it as <ifdef code="ca_list_items.schlagwort_liste">?  Would you be able to share the code that did ultimately work for you? Thanks again!
  • edited September 2017

    Hi! Glad to have helped you! In our ca_objects_default_html.php I call the related terms by <unit relativeTo="ca_list_items" restrictToRelationshipTypes="schlagwort"> which shows nicely. Here is the full code, with an additional ifcount to only show related terms if there are any. Feel free to ask again if that’s not clear enough. Have a nice evening!

    <ifcount code="ca_list_items" restrictToRelationshipTypes="schlagwort" min="1">    
            <unit relativeTo="ca_list_items" restrictToRelationshipTypes="schlagwort" delimiter="</br>">   <l>^ca_list_items.preferred_labels.name_singular</l></unit><HR>
  • This is awesome, thanks so much!  The ca_list_items_default_html.php file needs some re-formatting to look pleasant, but everything works!

    In case others need this, the metadata element containing the vocabulary list needed to be bound to object <-> vocabulary term relationships', rather than to objects, with a defined 'object <-> vocabulary term' relationship type restriction.
  • edited October 2017
    NOTE: Don't do this! It's causing errors in the apache log. I'll post a solution when/if I figure this out.

    This was very useful. Here's something I added, which changes the objects detail page (ca_objects_default_html.php) so that the link to the related term goes to the browse page rather than the detail page. I find the browse page is more useful and looks nicer.

    Change the following line:

    {{{<unit relativeTo="ca_objects_x_vocabulary_terms" delimiter="<br/>"><unit relativeTo="ca_list_items"><l>^ca_list_items.preferred_labels.name_plural</l></unit> (^relationship_typename)</unit>}}}


    {{{<unit relativeTo="ca_objects_x_vocabulary_terms" delimiter="<br/>"><unit relativeTo="ca_list_items"><?php print "<a href=\"/index.php/Browse/objects/facet/term_facet/id/"?>ca_list_items.item_id <?php print "/view/images/key/\">"?>^ca_list_items.preferred_labels.name_plural</a></unit> (^relationship_typename)</unit>}}}

    I used some ugly php to print the browse link around the ^ca_list_items.item_id.  But I couldn't find a cleaner way to make it work using display templates. It would, for example, be nice if there was a way to get <l></l> links in display templates to jump to browse instead of detail. If there's a better way, please share!

  • Hi Scottcampbell, thanks for posting your idea! Hopefully you’ll get it working, would be interested to try!
Sign In or Register to comment.