| View previous topic :: View next topic |
| Author |
Message |
qq_bbq
Joined: 05 Jul 2009 Posts: 114
|
Posted: Feb 27, 2010 11:02 am Post subject: How to add additional <IF> templates? |
|
|
For example, in table "Files" I added a field with the name of "new_field" and the type of field is ENUM with values 'AB','BC','CD'
In download0.html template, I want to add <IF> templates like this:
<TMPL_IF AB>
Show text
</IF>
<TMPL_IF BC>
Show text
</IF>
<TMPL_IF CD>
Show text
</IF>
I tried to look in index.cgi and other files for example but can't find anything relevant. |
|
| Back to top |
|
 |
admin Site Admin

Joined: 22 Mar 2006 Posts: 1126
|
Posted: Mar 02, 2010 6:32 am Post subject: |
|
|
If you just added fields - it will not work that way.
TMPL_IF tag coming from HTML::Template module and could work only with variables passed from Perl code.
You'd better use javascript for your needs. |
|
| Back to top |
|
 |
qq_bbq
Joined: 05 Jul 2009 Posts: 114
|
Posted: Mar 02, 2010 9:08 am Post subject: |
|
|
Please post an example of how to add additional <IF> tags or as you say, pass the variables from Perl code.
In table "Files" I added a field with the name of "new_field" and the type of field is ENUM with values 'AB','BC','CD' |
|
| Back to top |
|
 |
qq_bbq
Joined: 05 Jul 2009 Posts: 114
|
Posted: Mar 02, 2010 9:08 am Post subject: |
|
|
| Is the codes encrypted or where would I find the HTML::Template that calls the values from database? |
|
| Back to top |
|
 |
qq_bbq
Joined: 05 Jul 2009 Posts: 114
|
Posted: Mar 05, 2010 9:07 am Post subject: |
|
|
| Support? |
|
| Back to top |
|
 |
mrperl
Joined: 06 Mar 2010 Posts: 65
|
Posted: Mar 06, 2010 2:06 pm Post subject: Re: How to add additional <IF> templates? |
|
|
Hi qq.
Just passing variables to an existing template referred to in index.cgi
is easy.
Make a backup of the original .cgi and template first. Then ...
Here's an example of adding my_var parameter in index.cgi:
| Code: |
my $val = 1;
$ses->PrintTemplate("whatever.html",
'gen_ip' => $gen_ip,
'gen_user' => $gen_user,
'rec_user' => $rec_user,
my_var => $val,
);
|
and in Templates/whatever.html
| Code: |
<TMPL_IF my_var>
Show text
</IF>
|
You will have generate the data for $val first, whether that comes
from a MySQL table or is calculated. And you will have to modify the
relevant template to expect that parameter.
Sometimes that is obvious how to do, and sometimes not so much.
Enjoy, mrperl.
Last edited by mrperl on Mar 08, 2010 10:41 am; edited 1 time in total |
|
| Back to top |
|
 |
qq_bbq
Joined: 05 Jul 2009 Posts: 114
|
Posted: Mar 08, 2010 3:48 am Post subject: |
|
|
| Thanks for that, I want the $var read from MySQL table, how to do that? |
|
| Back to top |
|
 |
mrperl
Joined: 06 Mar 2010 Posts: 65
|
Posted: Mar 08, 2010 10:43 am Post subject: |
|
|
For database values, read index.cgi, find some database code that is similar
to what you want to do, and either extend it or cut-and-paste and replace
this line with your logic in the above example:
Often it is easy, but sometimes not so much. |
|
| Back to top |
|
 |
qq_bbq
Joined: 05 Jul 2009 Posts: 114
|
Posted: Mar 11, 2010 9:07 am Post subject: |
|
|
| sibsoft support can you please elaborate on this? |
|
| Back to top |
|
 |
|