Bug 19360 - Give items URL a link text
Summary: Give items URL a link text
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Josef Moravec
URL:
Keywords:
: 8090 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-09-24 20:51 UTC by Alex Buckley
Modified: 2022-02-22 22:51 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 19360 - Give items URL a link text (10.58 KB, patch)
2017-09-25 04:21 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 19360 - Added missing atomicupdate SQL file (3.12 KB, patch)
2017-10-06 00:41 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 19360 - Give items URL a link text (10.64 KB, patch)
2017-10-06 13:31 UTC, David Bourgault
Details | Diff | Splinter Review
Bug 19360 - Added missing atomicupdate SQL file (3.18 KB, patch)
2017-10-06 13:31 UTC, David Bourgault
Details | Diff | Splinter Review
OPAC with and without Link_text (37.62 KB, image/png)
2017-10-06 13:47 UTC, David Bourgault
Details
Bug 19360 - Give items URL a link text (11.58 KB, patch)
2018-01-26 16:33 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 19360 - Added missing atomicupdate SQL file (3.25 KB, patch)
2018-01-26 16:34 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Schema changes (2.60 KB, patch)
2018-01-26 16:34 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Buckley 2017-09-24 20:51:32 UTC
Instead of directly displaying the URL entered into the URI (Uniform Resource Identifier) field the patch attached to this bug report will allow the user to input a link text to be displayed instead of the URL on the intranet and OPAC detail page.
Comment 1 Alex Buckley 2017-09-25 04:21:42 UTC
Created attachment 67343 [details] [review]
Bug 19360 - Give items URL a link text

This patch allows a user to write in a link text when adding an item to
a MARC record in addition to a URI. The link text is displayed instead
of the URI (only if a link text has been entered, otherwise the URI
value is displayed) which makes the link more readable.

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g. https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference to an
previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an item.
When adding the item notice there is a 'Link text' option write in an
appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT
Comment 2 Alex Buckley 2017-09-25 04:36:14 UTC
When running the QA test tool all files pass except the detail.tt (see below) I reverted the changes I made and it still fails, so I believe that it is a bug introduced by a previous patch. I have written a bug report for this template (bug 19363) 

 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
   OK	  forbidden patterns
   OK	  git manipulation
   OK	  spelling
   OK	  tt_valid
   FAIL	  valid_template
		Attempt to reload Koha/Template/Plugin/Koha.pm aborted.
Compilation failed in require at /usr/lib/x86_64-linux-gnu/perl5/5.20/Template/Plugins.pm line 206.
Comment 3 Katrin Fischer 2017-09-25 04:38:35 UTC
Hi Alex, I think this might be a duplicate to bug 15352. Maybe you could take a look and help fixing it?
Comment 4 Katrin Fischer 2017-09-25 04:40:32 UTC
Hm, maybe only touching the same area
Comment 5 David Bourgault 2017-10-05 14:04:47 UTC
I followed the test plan up to step 8, but I still got an database error message when trying to add an item :
DBIx::Class::Storage::DBI::_dbh_execute(): Unknown column 'me.link_text' in 'field list' at /inlibro/git/koha-master-dev-inlibro/Koha/Objects.pm line 92

Looking at the commit, I didn't see any SQL files, did you forget to add it?
Comment 6 Dominic Pichette 2017-10-05 18:14:01 UTC
Can't find any SQL either...
Comment 7 Alex Buckley 2017-10-06 00:41:47 UTC
Created attachment 67662 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g.
https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference
to an previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an
item.
When adding the item notice there is a 'Link text' option write in
an appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT
Comment 8 Alex Buckley 2017-10-06 00:43:14 UTC
Hi David

Sorry I missed the SQL atomicupdate files in the first patch, I have just attached them in this second patch, can you please test again?
Comment 9 David Bourgault 2017-10-06 13:31:14 UTC
Created attachment 67706 [details] [review]
Bug 19360 - Give items URL a link text

This patch allows a user to write in a link text when adding an item to
a MARC record in addition to a URI. The link text is displayed instead
of the URI (only if a link text has been entered, otherwise the URI
value is displayed) which makes the link more readable.

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g. https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference to an
previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an item.
When adding the item notice there is a 'Link text' option write in an
appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 10 David Bourgault 2017-10-06 13:31:17 UTC
Created attachment 67707 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g.
https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference
to an previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an
item.
When adding the item notice there is a 'Link text' option write in
an appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 11 David Bourgault 2017-10-06 13:34:49 UTC
Tested according to test plan, worked as announced.

Note: I find it easier to update the DB by running installer/data/mysql/updatedatabase.pl than by changing the version number.

I think it would be preferable to have the 'Link Text' input right under the 'URI' input, but from what I understand of the code this would require moving many things around, for a small benefit, so not a priority.
Comment 12 Owen Leonard 2017-10-06 13:35:41 UTC
In my test the link text didn't appear in the OPAC. It read "Link to resource" instead. David did you not find that to be the case?
Comment 13 David Bourgault 2017-10-06 13:47:55 UTC
Created attachment 67711 [details]
OPAC with and without Link_text

Are you editing the marc 856$u field or the item field?
When adding an item (cataloguing/additem.pl) I had an input field for "k - Link text" and "u - URI".

I attached a picture of what it looked like for me in the OPAC.
Comment 14 Josef Moravec 2017-12-22 16:14:02 UTC
Alex,
please make the changes to Koha::Schema namespace a separate patch. It always should be done this way and generated by misc/devel/update_dbix_class_files.pl.

Also the patches need rebase.
Comment 15 Nick Clemens (kidclamp) 2018-01-26 16:33:59 UTC
Created attachment 70967 [details] [review]
Bug 19360 - Give items URL a link text

This patch allows a user to write in a link text when adding an item to
a MARC record in addition to a URI. The link text is displayed instead
of the URI (only if a link text has been entered, otherwise the URI
value is displayed) which makes the link more readable.

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g. https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference to an
previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an item.
When adding the item notice there is a 'Link text' option write in an
appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 16 Nick Clemens (kidclamp) 2018-01-26 16:34:03 UTC
Created attachment 70968 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Test plan:
1. Add a MARC record (of any framework)

2. Add an item making sure to write in a URL e.g.
https://www.google.com

3. Notice on the additem page there is no 'Link text' input

4. Submit the add item form

5. Search for the item in the intranet and OPAC and notice that the
whole URL is displayed, which would get annoying if the URL is long

6. Apply patch

7. Update the database by going to Administration->Global system
preferences-> local use and change the 'version' system preference
to an previous version and then click 'Save'

8. This will prompt the update process

9. After going through the update process repeat step 1 and add an
item.
When adding the item notice there is a 'Link text' option write in
an appropriate name e.g. 'Google' and write in the URI value

10. Submit the form

11. Repeat step 5 and notice that the link text value is displayed
instead of the URL

12. Click on the link and check that it works

13. Add another item to a record and write in a URI but no link text
value

14. Search for the item in intranet and OPAC and notice that when no
link text is entered but a URI is then the URI is displayed

Sponsored-By: Catalyst IT

Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Comment 17 Nick Clemens (kidclamp) 2018-01-26 16:34:06 UTC
Created attachment 70969 [details] [review]
Schema changes
Comment 18 Nick Clemens (kidclamp) 2018-01-26 16:35:22 UTC
Was an easy rebase, split the schema updtaes to separate patch and added cfhanges to kohastructure and deleteditems table - very cool feature
Comment 19 Josef Moravec 2018-02-05 08:51:38 UTC
Comment on attachment 70967 [details] [review]
Bug 19360 - Give items URL a link text

Review of attachment 70967 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
@@ +1215,4 @@
>                  <th id="item_priority" data-colname="item_priority">Item hold queue priority</th>
>          [% END %]
>          [% IF ( ShowCourseReservesHeader ) %]
> +                <th id="item_coursereserves">Course reserves</th>

Why do you changed this line? How it is related to this issue?
Comment 20 Josef Moravec 2018-02-05 08:54:43 UTC
Comment on attachment 70968 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Review of attachment 70968 [details] [review]:
-----------------------------------------------------------------

::: installer/data/mysql/atomicupdate/Bug-19360_Add_Link_text_field_to_items.sql
@@ +9,5 @@
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'IR', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'KT', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'SER', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'SR', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'VR', NULL)

I think you should add this field only to frameworks that does exist, have field 952 defined and 952$k not defined.

Also, this field needs to be added to installer data.
Comment 21 Katrin Fischer 2018-02-05 09:36:09 UTC
Hm, we don't have a lot of subfields left and $k and $u are rather far apart in the form, so editing won't be nice. I'd prefer something like url|text and maybe make the field repeatable as well in the future. with $k and $u separate, this would be a lot harder. We could also think about a plugin hiding the way we store the data but displaying it nicely.

This patch is in competition with bug 18760 for the last available free subfield $k.
Comment 22 Josef Moravec 2018-02-05 09:46:59 UTC
(In reply to Katrin Fischer from comment #21)
> Hm, we don't have a lot of subfields left and $k and $u are rather far apart
> in the form, so editing won't be nice. I'd prefer something like url|text
> and maybe make the field repeatable as well in the future. with $k and $u
> separate, this would be a lot harder. We could also think about a plugin
> hiding the way we store the data but displaying it nicely.
> 
> This patch is in competition with bug 18760 for the last available free
> subfield $k.

I agree, the plugin and only one field in database looks like better aproach here. We need the link text to bind with the URL - imagine somebody wants to have more then one URL field on item...
Comment 23 Alex Buckley 2018-02-28 02:15:59 UTC
Thanks for the comments. Sorry I have been travelling for the last few months and so haven't worked on this for a little while, however I am back into it now and am keen to push it forward. 

So Katrin and Josef to clarify would you like a single database field holding both the uri and link text with a delimiter? 

Then when the user loads the item page the value of this field is split at the delimiter and the URL is set as the form action and the link text is displayed?

If so, couldn't I simply remove the $k subfield and store this data value (with a data delimiter) in the $u subfield, rather than adding a brand new field url|text?

I am not familiar with Koha plugins so I've had a look at the kitchen sink example plugin and it looks like I'd need to make a tool plugin and it would need to be accessed via a link in the cataloguing/addbiblio.tt file.

The .tt file of this plugin will contain two inputs (url and link text inputs) which the backend logic concatenates and separates with a delimiter before this data value is stored in the 952$u database field of marc_subfield_structure database table.
Comment 24 Katrin Fischer 2018-02-28 06:28:40 UTC
Hi Alex, welcome back!

> If so, couldn't I simply remove the $k subfield and store this data value
> (with a data delimiter) in the $u subfield, rather than adding a brand new
> field url|text?

Yes, I think that was the thought, also to keep the last subfield $k free for now.

> 
> I am not familiar with Koha plugins so I've had a look at the kitchen sink
> example plugin and it looks like I'd need to make a tool plugin and it would
> need to be accessed via a link in the cataloguing/addbiblio.tt file.

Sorry, need to clarify. There are different kinds of plugins in Koha :) I was thinking of a value builder that you can link to the subfield via the framework configuration (look for plugin as an option there). It's older and a bit simpler than the new plugins. We use one for dateacccessioned in items, and some others are present in the record, as the helpers for the 00x fields or the authority linker.

> The .tt file of this plugin will contain two inputs (url and link text
> inputs) which the backend logic concatenates and separates with a delimiter
> before this data value is stored in the 952$u database field of
> marc_subfield_structure database table.

That was the idea - but my initial suggestion of | is not good I think. If you mark $u repeatable in the frameworks, Koha uses | for sorting multiples. Might have to think about something else, that is no tin a URL.
Comment 25 Alex Buckley 2018-03-12 10:12:58 UTC
Thanks very much Katrin! I started work on writing the value builder this evening, based on dateacccessioned.pl. Will hopefully have it ready to test by the end of the week.
Comment 26 Katrin Fischer 2019-04-28 12:53:29 UTC
*** Bug 8090 has been marked as a duplicate of this bug. ***
Comment 27 Liz Rea 2021-11-19 18:37:06 UTC
Hi,

This is still a really good idea, and people are still asking for this feature - what are the chances of work continuing on this bug? Seems like it's only getting more common for libraries to have one item that they have many different online sources for!

Cheers,
Liz
Comment 28 Hayley Pelham 2021-11-21 20:48:20 UTC
Hi Liz,

Marking as new as I don't have time to work on this at the moment, hopefully someone else will pick it up or I'll try to give it a go over Christmas!
Comment 29 Liz Rea 2021-11-23 18:05:08 UTC
Christmastime is a perfectly acceptable timeline if you have a chance to get to it :D
Comment 30 David Cook 2022-02-22 22:44:26 UTC
Comment on attachment 70968 [details] [review]
Bug 19360 - Added missing atomicupdate SQL file

Review of attachment 70968 [details] [review]:
-----------------------------------------------------------------

::: installer/data/mysql/atomicupdate/Bug-19360_Add_Link_text_field_to_items.sql
@@ +9,5 @@
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'IR', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'KT', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'SER', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'SR', NULL),
> +(952, 'k', 'Link text', 'Link text', 0, 0, 'items.link_text', 10, 1, 0, 'VR', NULL)

Good call. I did some digging around and it looks like once upon a time 952$k did exist.

git log --follow --name-only -- installer/data/mysql/en/marcflavour/marc21/mandatory/marc21_framework_DEFAULT.sql
git show f8e9fb6445dadbdef91e13a253c9c6bcb75e0eec
+INSERT INTO `marc_subfield_structure` VALUES ('952', 'k', 'Call number (similar to 852 $k $h $i $m combined)', 'Call number', 0, 0, 'items.itemcallnumber', 10, '', '', NULL, 0, 0, '', '', '');
Comment 31 David Cook 2022-02-22 22:51:59 UTC
Locally, we have a few customizations for this one, but the one typically used is to just render "Link to resource" instead of the URI as the link text. (The main complaint we got was just that long/complicated URLs are annoying/ugly.)

(Also added support for URLLinkText, and the option to use the item's item type as the link text.)

It's a lightweight touch that doesn't require any schema changes, although it wouldn't be as full featured as this one. 

But just a thought.