XFileSharing Pro - How to add additional <IF> templates?

Message
Author
qq_bbq
Posts: 122
Joined: Jul 05, 2009 11:33 pm

How to add additional <IF> templates?

#1 Postby qq_bbq » Feb 27, 2010 11:02 am

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.

admin
Site Admin
Posts: 1839
Joined: Mar 22, 2006 12:32 pm

#2 Postby admin » Mar 02, 2010 6:32 am

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.

qq_bbq
Posts: 122
Joined: Jul 05, 2009 11:33 pm

#3 Postby qq_bbq » Mar 02, 2010 9:08 am

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'

qq_bbq
Posts: 122
Joined: Jul 05, 2009 11:33 pm

#4 Postby qq_bbq » Mar 02, 2010 9:08 am

Is the codes encrypted or where would I find the HTML::Template that calls the values from database?

qq_bbq
Posts: 122
Joined: Jul 05, 2009 11:33 pm

#5 Postby qq_bbq » Mar 05, 2010 9:07 am

Support?

mrperl
Posts: 65
Joined: Mar 06, 2010 11:40 am

Re: How to add additional <IF> templates?

#6 Postby mrperl » Mar 06, 2010 2:06 pm

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: Select all

   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: Select all

<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.

qq_bbq
Posts: 122
Joined: Jul 05, 2009 11:33 pm

#7 Postby qq_bbq » Mar 08, 2010 3:48 am

Thanks for that, I want the $var read from MySQL table, how to do that?

mrperl
Posts: 65
Joined: Mar 06, 2010 11:40 am

#8 Postby mrperl » Mar 08, 2010 10:43 am

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:

Code: Select all

 my $val = 1; 
Often it is easy, but sometimes not so much.

qq_bbq
Posts: 122
Joined: Jul 05, 2009 11:33 pm

#9 Postby qq_bbq » Mar 11, 2010 9:07 am

sibsoft support can you please elaborate on this?