Re: [Koha-devel] [Koha] Help needed in Template
2010/8/8 Nitesh Rijal <rijal.it@gmail.com>:
Dear all.. I have a problem while making conditional display in template. I have a variable called fulltext. When I write <!-- TMPL_VAR NAME="fulltext" -->, it gets displayed in the output. Its value is either TRUE or FALSE. Now what I want to do is, show or hide a block of code on the basis of this variable. If it is TRUE then show a link and if it is FALSE then hide a link. How am I supposed to do this?? What should the <!-- TMPL_IF --> block and <!-- TMPL_ELSE --> block look like??? Please Help.
Hi Nitesh What you need to do is not set an actual value if it is false. So it should contain a value if true, and be undefined if false. Then you can simply do <!-- TMPL_IF NAME="fulltext"--> block of code <!-- /TMPL_IF --> This type of question is much better suited to the development list, which I have cc'd please reply to there only (I have left the other list in case you aren't subscribed) Chris
Actually, I have the value as TRUE and FALSE. Isn;t there anyway to execute the code of it is TRUE like: if (fulltetxt == TRUE) do this else do this This is what I need, I have no idea how to set a variable true or false before passing to the template. The interesting thing is that the same code is working for me in KOHA 3.0.3 in Debian, but it is not working in KOHA 3.0.6 in Ubuntu. Please help. On Sun, Aug 8, 2010 at 4:05 PM, Chris Cormack <chris@bigballofwax.co.nz>wrote:
Dear all.. I have a problem while making conditional display in template. I have a variable called fulltext. When I write <!-- TMPL_VAR NAME="fulltext" -->, it gets displayed in the output. Its value is either TRUE or FALSE. Now what I want to do is, show or hide a block of code on the basis of
2010/8/8 Nitesh Rijal <rijal.it@gmail.com>: this
variable. If it is TRUE then show a link and if it is FALSE then hide a link. How am I supposed to do this?? What should the <!-- TMPL_IF --> block and <!-- TMPL_ELSE --> block look like??? Please Help.
Hi Nitesh
What you need to do is not set an actual value if it is false. So it should contain a value if true, and be undefined if false. Then you can simply do <!-- TMPL_IF NAME="fulltext"--> block of code <!-- /TMPL_IF -->
This type of question is much better suited to the development list, which I have cc'd please reply to there only (I have left the other list in case you aren't subscribed)
Chris _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel
-- Nitesh Rijal BE IT rijal.it@gmail.com http://niteshrijal.com.np http://facebook.com/openrijal http://twitter.com/openrijal +9779841458173
On 8 August 2010 22:33, Nitesh Rijal <rijal.it@gmail.com> wrote:
Actually, I have the value as TRUE and FALSE. Isn;t there anyway to execute the code of it is TRUE like: if (fulltetxt == TRUE) do this else do this This is what I need, I have no idea how to set a variable true or false before passing to the template.
No you can't do that, you can use TMPL_EXPR but this is unsafe, the only safe way to do it is to not set the variable to false, but just to empty. my $fulltext=''; if (some condition){ $fulltext = 1; } $template->param('fulltext' => $fulltext); Then in the template <!-- TMPL_IF NAME="fulltext" --> Chris
participants (2)
-
Chris Cormack -
Nitesh Rijal