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]
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>
(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?
(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
Created attachment 183855 [details] 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.
Created attachment 184073 [details] [review] Bug 40285: Display patron attribute description in "Patrons statistics" report
This is how I would do it.