Adding an external link to the context menu

33 views
Skip to first unread message

drba...@ucalgary.ca

unread,
Jan 11, 2022, 2:51:54 PM (6 days ago) Jan 11
to AtoM Users
Hello,

I'm wondering what the best way to accomplish this is. We need to add a link to an external website to the context menu in AtoM (the one that has the export and browse digital object links, etc.).

The link will change based on the archival description that is currently displayed. If possible, I'm hoping to populate the link with an ID number of some kind, which I could probably store as a reference code in each description. The URL might look like https://whatever.system.com?external_id=<value retrieved from reference code or other field>.

Is this possible? I'm guessing it would require a plugin for that sort of logic? If so, do you have any sample code I could take a look at?

Thanks!

Damian

Dan Gillean

unread,
Jan 12, 2022, 10:33:29 AM (5 days ago) Jan 12
to ICA-AtoM Users
Hi Damian, 

One of our developers has suggested that, if you are able to use the slug (i.e. use the settings so the slug is generated from your reference code), then you can do this with relatively little code. For example, adding the following snippet: 

<li class="separator"><h4><?php echo __('External site'); ?></h4></li>

<a href="https://whatever.system.com?external_id=<?php echo $resource->slug; ?>" target="_blank">
  <?php echo __('Go to external site'); ?>
</a>


To this file: 
Would result in the following "External site" heading and link in the context menu: 

custom-link.png

Doing this in a custom theme plugin will make it easier to upgrade in the future - otherwise you'll need to reapply these changes every time you upgrade. 

Cheers, 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him


--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/f861dc37-03cc-49d9-a6e8-c97628193682n%40googlegroups.com.

drba...@ucalgary.ca

unread,
Jan 12, 2022, 1:59:12 PM (5 days ago) Jan 12
to AtoM Users
Thanks for your reply, Dan.

Unfortunately, we need to use an ID from this external system, so we'd need a way to add it to existing and new records. Maybe the Alternate Identifier field could be used instead, but either way, I think we need to retrieve from a field attached to an archival description.

Damian

Dan Gillean

unread,
Jan 14, 2022, 12:55:42 PM (3 days ago) Jan 14
to ICA-AtoM Users
Hi Damian, 

You may want to refine this locally, but one of our developers has provided an updated snippet that should serve as a good starting point. 

The following will take the first alternative identifier value  with a label of "external_id" and append it to a link in the context menu, in a similar way as shown in the screenshot included in my last post. If you need it to pick a specific alt-ID when there are multiple using the "external_id" label, or else fail instead, you'll have to do further testing and code changes yourself. Other alternative identifiers with different labels will be ignored. 

Similarly, this code does not factor in multilingual functionality - currently the label and link that will appear in the context menu are hardcoded in this snippet. Adjust as necessary. 

If no alternative identifier matching the label criteria is present, then the context menu link will not display. 

Try adding the following to the same file linked in the last post: 

<?php
    $externalId = $resource->getPropertyByName(
        'external_id',
        ['scope' => 'alternativeIdentifiers']
    )->getValue(['cultureFallback' => true]);
?>

<?php if ($externalId) { ?>

  <li class="separator"><h4><?php echo __('External site'); ?></h4></li>

  <a href="https://whatever.system.com?external_id=<?php echo $externalId; ?>" target="_blank">

    <?php echo __('Go to external site'); ?>
  </a>
<?php } ?>

Hope that helps! 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him

drba...@ucalgary.ca

unread,
9:35 AM (14 hours ago) 9:35 AM
to AtoM Users
Hi Dan,

Thank you, and please pass along my thanks to the developer. This should be more than enough to get me started!

Cheers,

Damian

Reply all
Reply to author
Forward
0 new messages