[Bug 40285] New: Add template plugin to get patron attribute by code
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 Bug ID: 40285 Summary: Add template plugin to get patron attribute by code Change sponsored?: --- Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Templates Assignee: koha-bugs@lists.koha-community.org Reporter: oleonard@myacpl.org QA Contact: testopia@bugs.koha-community.org We have template plugins for getting descriptions of things like item types, collection codes, and patron categories: [% AuthorisedValues.GetByCode('Bsort1', loopfilte.filter ) | html %] It would be useful to have the same thing for getting a patron attribute's description by the code. Something like: [% ExtendedAttributeTypes.GetName( attribute_code ) %] This could be used on a page like moremember.pl: **Additional attributes and identifiers** - [Attribute description]: [Attribute value] -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lisette@bywatersolutions.co | |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@gmail.com --- Comment #1 from Jonathan Druart <jonathan.druart@gmail.com> ---
From Mattermost
It can be done using Koha::Patron::Attribute::Types->find( $code )->description, if I understand the need correctly. But we really should not need a TT plugin for that We should have the koha object passed to the template, and so access the description attribut, and this is what we are doing already actually, at least in members/moremember.tt: 358 <span class="label">[% item.type.description | html %]: </span> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 --- Comment #2 from Owen Leonard <oleonard@myacpl.org> --- (In reply to Jonathan Druart from comment #1)
But we really should not need a TT plugin for that
Is there something about patron attributes that is different from item types, collection codes, etc. that make the template plugin unnecessary? Or would you also consider those to be unnecessary? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 --- Comment #3 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to Owen Leonard from comment #2)
(In reply to Jonathan Druart from comment #1)
But we really should not need a TT plugin for that
Is there something about patron attributes that is different from item types, collection codes, etc. that make the template plugin unnecessary? Or would you also consider those to be unnecessary?
It depends :D Sometimes it's just bad coding, and we are lazy and need a plugin to display the description. Sometimes it is for performance purpose (with REST API calls in mind): eg. on the holdings table of a bib record, you don't want to embed the the item type object for each items. But we should not have a TT plugin anyway IMO. We should prefer to have a mapping { code => description } and retrieve the description using item.item_type. In the case of moremember we already have the attribute type object and we can so access its description: attribute.type.description. IF the problem is performance (say you are going to display thousands of attributes), then you won't want to access/fetch the attribute type for each attribute: you will eventually want to use the same mapping mechanism as above.
From the controller: $attr_types_description_mapping = { map { $_->code => $_->description } Koha::Attribute::Types->search->as_list }; Pass it to the template, then loop on the attributes in the template and display the description of the type: [% FOR attribute IN patron_attributes %] [% attr_types_description_mapping.item(attribute.code) %] [% END %]
Hope that makes sense. Let me know if you have additional questions! POD for the item method: https://template-toolkit.org/docs/manual/VMethods.html#section_item -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 --- Comment #4 from Owen Leonard <oleonard@myacpl.org> --- Created attachment 183855 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=183855&action=edit Screenshot showing code instead of description This screenshot shows the use case I'm thinking of, under Reports -> Statistics wizards -> Patrons. If you include a search term in a patron attribute, the results screen shows the attribute you searched and the term you submitted. In this case the script only returns the patron attribute code. To me it's simpler to have the option of using a template plugin rather than rewrite the report. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 --- Comment #5 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 184073 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=184073&action=edit Bug 40285: Display patron attribute description in "Patrons statistics" report -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 --- Comment #6 from Jonathan Druart <jonathan.druart@gmail.com> --- This is how I would do it. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=40285 Owen Leonard <oleonard@myacpl.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |WONTFIX Status|NEW |RESOLVED -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org