Bug 32453 - Object methods _result and _resultset methods not available in templates
Summary: Object methods _result and _resultset methods not available in templates
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Kyle M Hall (khall)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-12 18:11 UTC by Kyle M Hall (khall)
Modified: 2023-04-28 07:22 UTC (History)
2 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 32453: Allow template access to _result/_resultset (1.29 KB, patch)
2023-04-27 14:32 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 32453: Allow template access to _result/_resultset (1.35 KB, patch)
2023-04-27 16:49 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall (khall) 2022-12-12 18:11:23 UTC
There are times where it would be really useful to be able to access the underying result or resultset within out templates. However, Template Toolkit itself disallows this, but you can disable this feature by setting the $Template::Stash::PRIVATE package variable to a false value.

$Template::Stash::PRIVATE = undef;   # now you can thing._private

The alternate would be to rename _result and _resultset or just provide non-prefixed aliases as result and resultset respectively.
Comment 1 Kyle M Hall (khall) 2023-04-27 14:18:23 UTC
If you really need to, you can add
[% PERL %]$Template::Stash::PRIVATE = undef;[% END %]
to the top of your notice to all access to those methods.
Comment 2 Kyle M Hall (khall) 2023-04-27 14:32:33 UTC
Created attachment 150302 [details] [review]
Bug 32453: Allow template access to _result/_resultset

There are times where it would be really useful to be able to access the underying result or resultset within out templates. However, Template Toolkit itself disallows this, but you can disable this feature by setting the $Template::Stash::PRIVATE package variable to a false value.

Test Plan:
1) Modify the CHECKOUT notice, add "*[% biblio._result %]*" to your
   notice
2) Generate a CHECKOUT notice, note you only get "**"
3) Apply this patch
4) Restart all the things!
5) Generate a CHECKOUT notice, note you know get something like
   "*Koha::Schema::Result::Biblio=HASH(0x564f907a3390*" in your notice!
Comment 3 Lucas Gass (lukeg) 2023-04-27 16:49:37 UTC
Created attachment 150310 [details] [review]
Bug 32453: Allow template access to _result/_resultset

There are times where it would be really useful to be able to access the underying result or resultset within out templates. However, Template Toolkit itself disallows this, but you can disable this feature by setting the $Template::Stash::PRIVATE package variable to a false value.

Test Plan:
1) Modify the CHECKOUT notice, add "*[% biblio._result %]*" to your
   notice
2) Generate a CHECKOUT notice, note you only get "**"
3) Apply this patch
4) Restart all the things!
5) Generate a CHECKOUT notice, note you know get something like
   "*Koha::Schema::Result::Biblio=HASH(0x564f907a3390*" in your notice!

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Marcel de Rooy 2023-04-28 07:22:41 UTC
Not sure if we should go this way and put such constructs in our templates too.
This needs a broader dev discussion.
Please trigger it by mailing dev list or putting it on dev meeting agenda.