It would be useful if news items could take advantage of template toolkit syntax.
Created attachment 114808 [details] [review] Bug 27334: Add Template Toolkit support to news items It would be useful if news items could take advantage of template toolkit syntax. Test Plan: 1) Apply this patch 2) Edit a news item 3) Add some TT to the content like "[% IF 1 %]It works![% END %]" 4) View the rendered news item on mainpage.pl 5) Note the TT is rendered correctly!
This patch won't apply to a sandbox - it gives a series of errors such as: String found where operator expected at /kohadevbox/koha/C4/NewsChannels.pm line 234, near "croak "ERROR PROCESSING TEMPLATE: "" (Do you need to predeclare croak?) syntax error at /kohadevbox/koha/C4/NewsChannels.pm line 234, near "croak "ERROR PROCESSING TEMPLATE: "" Compilation failed in require at /kohadevbox/koha/C4/Members.pm line 36.
Created attachment 115309 [details] [review] Bug 27334: Add Template Toolkit support to news items It would be useful if news items could take advantage of template toolkit syntax. Test Plan: 1) Apply this patch 2) Edit a news item 3) Add some TT to the content like "[% IF 1 %]It works![% END %]" 4) View the rendered news item on mainpage.pl 5) Note the TT is rendered correctly!
Created attachment 115310 [details] [review] Bug 27334: Add Template Toolkit support to news items It would be useful if news items could take advantage of template toolkit syntax. Test Plan: 1) Apply this patch 2) Edit a news item 3) Add some TT to the content like "[% IF 1 %]It works![% END %]" 4) View the rendered news item on mainpage.pl 5) Note the TT is rendered correctly! Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Works as described - nice addition!
It works as described, but as this changes a C4 module we should have some unit tests! As we are currently working on moving this code to the Koha namespace (bug 22544) adding new features might be a bit bad timing. :)
Created attachment 116159 [details] [review] Bug 27334: Add unit test
Created attachment 116467 [details] [review] Bug 27334: Add Template Toolkit support to news items It would be useful if news items could take advantage of template toolkit syntax. Test Plan: 1) Apply this patch 2) Edit a news item 3) Add some TT to the content like "[% IF 1 %]It works![% END %]" 4) View the rendered news item on mainpage.pl 5) Note the TT is rendered correctly! Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Created attachment 116468 [details] [review] Bug 27334: Add unit test Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Please fill the release notes.
Kyle, can you detail a bit more the need please? "It allows supports the use of Koha's TT plugins for data and price formatting and more!" Which "data"? And what "more"? :) Seems overkilled for price formatting only.
(In reply to Jonathan Druart from comment #11) > Kyle, can you detail a bit more the need please? > > "It allows supports the use of Koha's TT plugins for data and price > formatting and more!" > > Which "data"? And what "more"? :) > > Seems overkilled for price formatting only. Those are just basic examples. A good example would be a news item that shows different information to libraries based on what category they are.
(In reply to Kyle M Hall from comment #12) > (In reply to Jonathan Druart from comment #11) > > Kyle, can you detail a bit more the need please? > > > > "It allows supports the use of Koha's TT plugins for data and price > > formatting and more!" > > > > Which "data"? And what "more"? :) > > > > Seems overkilled for price formatting only. > > Those are just basic examples. A good example would be a news item that > shows different information to libraries based on what category they are. Logged-in patron's category you mean? How would you do that? We don't pass any variables to ->process.
(In reply to Jonathan Druart from comment #13) > (In reply to Kyle M Hall from comment #12) > > (In reply to Jonathan Druart from comment #11) > > > Kyle, can you detail a bit more the need please? > > > > > > "It allows supports the use of Koha's TT plugins for data and price > > > formatting and more!" > > > > > > Which "data"? And what "more"? :) > > > > > > Seems overkilled for price formatting only. > > > > Those are just basic examples. A good example would be a news item that > > shows different information to libraries based on what category they are. > > Logged-in patron's category you mean? How would you do that? We don't pass > any variables to ->process. My bad, I was thinking the logged in branch code.
So you don't need that, you can define several "item news" and set a different library for each of them.
(In reply to Jonathan Druart from comment #15) > So you don't need that, you can define several "item news" and set a > different library for each of them. That was just an example. The real power here is combining new with running perl in TT so we have access to any data in Koha. What would make this much better and more convenient is the ability to get a schema object via a TT plugin. That way we can get to the data without resorting to raw perl. What do you think?
Hm, wondering... if we could get any object, wouldn't that allow to get around permissions like the ones to access patron data? (might be totally misunderstanding things)
(In reply to Katrin Fischer from comment #17) > Hm, wondering... if we could get any object, wouldn't that allow to get > around permissions like the ones to access patron data? (might be totally > misunderstanding things) Yes, it would allow you to get around permissions.
(In reply to Kyle M Hall from comment #16) > That was just an example. The real power here is combining new with running > perl in TT so we have access to any data in Koha. What would make this much > better and more convenient is the ability to get a schema object via a TT > plugin. That way we can get to the data without resorting to raw perl. What > do you think? This sounds like it might be convenient for a developer but what staff interface user would actually have the knowledge or skill to make use of this? What's your current/expected use cases? It seems a bit too hypothetical to me at the moment.
Still not convinced and there are pending questions. Setting back to in discussion.
Bug 24865 highlights a good use case for this, though I feel we should probably limit the data we allow users to fetch using it similar to the notices..