Skip to content

Conversation

@maccabeelevine
Copy link
Member

@maccabeelevine maccabeelevine commented Oct 31, 2025

Use a data element to mark the type of link provided by the IdentifierLinker. Both BrowZine and Unpaywall provide at least two different types of links. It may be useful to hide (via css) a particular link type on some templates.

I.e. and example of custom CSS to hide BrowZine links that just point back to the link resolver:

.record-list.search-results-eds, .record.sourceEDS {
    .identifierLink[data-link-type="linkResolverOpenUrl"] {
        display: none;
    }
}

TODO

  • Test Demo
  • Test BrowZine
  • Test Unpaywall

@maccabeelevine
Copy link
Member Author

This could be either an alternative to #4774 or an additional mechanism.

  • It's more flexible as it can apply to any IdentifierLinker (BrowZine, Unpaywall, etc.) and regardless of the identifier (DOI, ISSN, etc.). And depending on the CSS selectors used, it can be applied differently to individual pages.
  • OTOH, in the use case where you want to disable a link type globally, BrowZine: Allow disabling individual bestIntegratorLink types #4774 is more efficient and (possibly) simpler to understand and implement.

@maccabeelevine maccabeelevine marked this pull request as ready for review October 31, 2025 16:20
'label' => 'Demonstrating ' . strtoupper($type) . " link for $id with icon "
. ($icon ?? '[null]'),
'localIcon' => $icon,
'linkType' => rand(0, 1) ? 'foo' : 'bar',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how 'real' the demo driver output is supposed to be...can improve this if needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it needs to be very realistic, but maybe calling these foo-link-type and bar-link-type would make the context less ambiguous if we use this for testing. Having too many foo and bar values can make things ambiguous sometimes.

@@ -1,5 +1,5 @@
<?php
$attribs = ['class' => 'identifierLink', 'data-instance' => $instance ?? 0];
$attribs = ['class' => 'identifierLinks', 'data-instance' => $instance ?? 0];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have renamed this wrapper element class to plural identifierLinks because

  1. It can contain any number of links (0-n) depending on what the data source returns
  2. I need an actual wrapper element identifierLink for each of those links.

Comment on lines 3 to 5
<div class="identifierLink"
<?php if (isset($link['linkType'])): ?>data-link-type="<?=$link['linkType']?>" <?php endif; ?>
>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapping the <a> in a <div>, we can remove the <br>. And so then hiding any individual identifierLink via CSS doesn't leave the whitespace.

Copy link
Member Author

@maccabeelevine maccabeelevine Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would have been to add the identifierLink class and linkType to the anchor element itself, and change its CSS display property from inline to block. But because it's an icon link it already has a custom display property. Seems safer to leave that alone.

echo $this->assetManager()->outputInlineScriptLink('identifierLinks.js');
?>
<span<?=$this->htmlAttributes($attribs)?>></span>
<div<?=$this->htmlAttributes($attribs)?>></div>
Copy link
Member Author

@maccabeelevine maccabeelevine Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This span-to-div change is not strictly necessary, but it was effectively a block-level element to begin with. So as long as I'm making various other potentially breaking changes to the templates and JS, may as well do this one.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @maccabeelevine -- see below for some comments/suggestions.

I'm not too concerned about the breaking changes since this functionality hasn't been released yet -- but it would be good to wrap this up before the 11.0 release, or else we'll have to worry a little more carefully about BC issues.

'label' => 'Demonstrating ' . strtoupper($type) . " link for $id with icon "
. ($icon ?? '[null]'),
'localIcon' => $icon,
'linkType' => rand(0, 1) ? 'foo' : 'bar',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it needs to be very realistic, but maybe calling these foo-link-type and bar-link-type would make the context less ambiguous if we use this for testing. Having too many foo and bar values can make things ambiguous sometimes.

@demiankatz demiankatz added this to the 11.0 milestone Nov 5, 2025
@maccabeelevine
Copy link
Member Author

I'm not too concerned about the breaking changes since this functionality hasn't been released yet -- but it would be good to wrap this up before the 11.0 release, or else we'll have to worry a little more carefully about BC issues.

Ok I forgot that IdentifierLinker itself is introduced in 11... this has been a very long release cycle. :) So yeah nothing really breaking here.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @maccabeelevine!

@demiankatz demiankatz merged commit f7c8597 into vufind-org:dev Nov 5, 2025
6 checks passed
@maccabeelevine maccabeelevine deleted the browzine-mark-link-type branch November 5, 2025 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants