Display Templates links to related terms
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
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!
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!
@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?
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.
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.
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.
Hi,
What this piece of code should do, is searching
objects
with criteriaca_list_items:^ca_list_items.item_id
, so when the list terms of an object correspond toitem_id
... I don't know why it returns also objects for which theiridno
containsitem_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!