Display Templates links to related terms

edited November 2016 in Pawtucket Help
Hi! 

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.

Comments

  • 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>^ca_object_representations.media.small</l><br/><l>^ca_objects.preferred_labels.name</l><br/></unit></ifcount>}}}

    {{{<ifcount code="ca_objects" min="2"><HR><H4>Related Objects</H4><unit relativeTo="ca_objects" delimiter=" "><l>^ca_object_representations.media.small</l><br/><l>^ca_objects.preferred_labels.name</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">    
        <H5>Schlagwörter</H5>
            <unit relativeTo="ca_list_items" restrictToRelationshipTypes="schlagwort" delimiter="</br>">   <l>^ca_list_items.preferred_labels.name_singular</l></unit><HR>
    </ifcount>
    }}}
  • 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>}}}

    to:

    {{{<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!
  • @kbecker and @ccas: I tried to follow your steps, but I couldn't achieve in getting the keywords hyperlinked to the related objects. Rather, I received some error of "Invalid detail type" as shown in the attached screenshot.

    Will someone help please?

    1920 x 452 - 3M
  • Did you coinfigure everything correctly in detail.conf? See my comment https://collectiveaccess.org/support/index.php?p=/discussion/comment/325103&#

  • Many many thanks @kbecker. My deep apology for my delayed response to you but your inputs in this forum actually rescued me from my trouble. I could indeed make my "related terms" properly hyperlinked to the relevant objects following your criteria.

    I will be immensely grateful if you could help in sorting out another problem which I have been unable to fix. I have uploaded here two images. First one is an image of the output of the ca_list_items_default_html.php page which I created as per your instructions. It is indeed showing the right kind of objects. However, I have been unable to customize the display of this page; especially the objects displayed are not properly aligned as you can see.

    How can I make this page look like the collections page as shown in my 2nd image? If I can do this, I will be happy.

    1344 x 739 - 253K
    1365 x 670 - 407K
  • Hi, glad that it worked for you. We don't show related items, instead we link to the appropriate browsing: https://bildpostkarten.uni-osnabrueck.de/frontend/index.php/Detail/terms/06_Freizeit

    I think you'd need to show the Code of ca_list_items_default_html.php here, but first try to compare this view with a a view where related items are shown correctly. That would at least be my approach.

  • You'll need to set some CSS around the output images to get formatting as in the 2nd image. You may also want to use a higher resolution image version.

  • Thank you @kbecker. It was such a satisfying experience to browse your site. I liked the way you designed the views for objects and collections.

    My work demands showing of the "related words". Hence, as you suggested, I am showing here the Code of ca_list_items_default_html.php. I had created this file by duplicating and modifying the ca_collections_default_html.php file in the detail view (following your comment in this forum November 2016).

    And the view which is displaying correctly for me is the ca_collections_default_html.php. I have attached this one as well.

    I guess I am not grasping something at the very basic level; and I am sorry for my ignorance.

  • Thank you @seth. Glad to read the helping comments from you. I indeed tried to work on the CSS. I inspected the elements in the browser; and attempted to touch up the relevant sections of the main.css in my theme. But unfortunately I am still clueless how to do that effectively for the display of a file which I created newly within the Details folder of my theme. Please help if you can.

    Regarding the images, if you are referring to the resolution of the uploaded images, yes these are low resolution scanned images of some old photographs. I thought, as I will require to upload several thousands of such archival photographs, it will be better to keep their resolutions low so that the speed of browsing is not hampered. Please correct me otherwise.

  • Will there be any help in this regard...? Please.

  • It's a web design problem. I can't help you without knowing what you're actually doing. Contact me at support@collectiveaccess.org with details about how to access the site and I'll take a look when I can.

  • edited February 2

    Hi Parasmoni,

    If you want to display a nice list of objects with images, related to a list item, just like the objects list that apprears in the content of a collection, try this:

    {{{<ifcount code="ca_objects" min="1">

             <div class="row">

                <div id="browseResultsContainer">

                   <?php print caBusyIndicatorIcon($this->request).' '.addslashes(_t('Loading...')); ?>

                </div><!-- end browseResultsContainer -->

             </div><!-- end row -->

             <script type="text/javascript">

                jQuery(document).ready(function() {

                   jQuery("#browseResultsContainer").load("<?php print caNavUrl($this->request, '', 'Search', 'objects', array('search' => 'ca_list_items:^ca_list_items.item_id'), array('dontURLEncodeParameters' => true)); ?>", function() {

                      jQuery('#browseResultsContainer').jscroll({

                         autoTrigger: true,

                         loadingHtml: '<?php print caBusyIndicatorIcon($this->request).' '.addslashes(_t('Loading...')); ?>',

                         padding: 20,

                         nextSelector: 'a.jscroll-next'

                      });

                   });

                });

             </script>

    </ifcount>}}}

    You should insert this code after the

          <div class="container">

             <div class="row">

                <div class='col-md-12 col-lg-12'>

    (Here is the result in my case: https://collections.univ-pau.fr/pub/index.php/Detail/terms/466)

  • Many many thanks darrigan. This is exactly what I have been looking for. Your codes have worked so nicely.

  • Hi darrigan, this is more of an SoS call to you. Your above codes have been working fine till recently when my collection was having few demo data. But now after entering several more actual data into my collection, I have seen that some unrelated objects are also shown as related to a list term. One common thing among these unrelated objects is that portions of their object_Ids are similar.

    Could you please help me in understanding why it is happening this way.

    I checked removing your codes and using kbecker's codes. This shows the correct objects related to a specific list term but the display is not as nice as yours.

  • edited March 17

    Hi,

    What this piece of code should do, is searching objects with criteria ca_list_items:^ca_list_items.item_id, so when the list terms of an object correspond to item_id... I don't know why it returns also objects for which their idno contains item_id...

    Maybe try to replace the criteria by: ca_list_items.item_id:^ca_list_items.item_id

    (it searches list_items.item_id equal to the wanted item_id)

    (It works for me...)

  • Yeah, ca_list_items.item_id:^ca_list_items.item_id has worked !

    Once again, many many thanks darrigan. 🙏🙏🙏

  • Happy to help you!

Sign In or Register to comment.