[Koha-bugs] [Bug 28883] Koha::Objects->_new_from_dbic doesn't work correctly in list context

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Sep 24 14:13:33 CEST 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28883

--- Comment #48 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
(In reply to Marcel de Rooy from comment #47)
> (In reply to Marcel de Rooy from comment #45)
> > git grep Context.Scalar on master
> > 
> > koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc:    [% IF
> > Context.Scalar(Context.Scalar(items, "filter_by_for_hold"), "count") %]
> > koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc:    [% SET
> > current   = Context.Scalar(orders, "filter_by_current") %]
> > koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc:    [% SET
> > cancelled = Context.Scalar(orders, "filter_by_cancelled") %]
> > 
> > I think we should not do these things in the templates. Doesnt look good to
> > me.
> > The double Scalar in the first line is horrible.
> 
> Additional note:
> If TT was doing things a bit smarter, this should work like we chain in perl:
> var countorders = [% biblio.orders.filter_by_current.count || 0 | html %];
> (In Perl the chain brings it in scalar context.)
> 
> But it fails. TT calls the orders method in LIST context. Explaining the
> horrible scalar stuff introduced.
> See also https://www.perlmonks.org/bare/?node_id=413941

We should be able to use the TT scalar plugin and do things like:

[% USE scalar %]
[% SET var = scalar.biblio.items %]

but I haven't checked it.

> Question remains then: Should we workaround that in the script or template?

I feel like we should do this stuffs in the controller and leave logic out of
TT, as much as possible.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list