Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Question about template parsing

Quote Reply
Question about template parsing
Hello,

In my link.html template I'm trying to do a comparison but it doesn't want to work.

U_GP is an extra field and RepAdjCost is a calculated value.

Here is the template comparisons I'm trying to work with, but I don't know why it's not working. Am I overestimating what the parse sub can do

Code:

<%if U_Username%>
<%if RepAdjCost < U_GP%>
<a href="<%db_cgi_url%>/equipme.cgi?add=<%ID%>&gp=<%RepAdjCost%>">Buy Item</a>
<%endif%>
<%if RepAdjCost > U_GP%>
Not enough gold
<%endif%>
<%endif%>

U_Username is just %Username% but the site is integrated with the software fromerly known as W3T :D

Any help and ideas would be appreciated

Quote Reply
Re: [phoule] Question about template parsing In reply to
Use lt for less than and gt for greater than.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Chewbaca] Question about template parsing In reply to
Hi Chewbacca, thanks for the quick response. I have tried subsituting lt and gt, but I thought lt & gt were for text comparisons, these are numbers and thought that it should therefore use the symbols?
Quote Reply
Re: [phoule] Question about template parsing In reply to
> and < are fine. As far as I know it isnt even possible to compare text. For example you can't do...

if (bob lt bill) {

...it makes no sense.

The code you have looks fine. This would definitely work with Links SQL 2+ but I'm not sure if it will with Links SQL 1.13 but it should.

Last edited by:

RedRum: Nov 11, 2001, 9:24 AM
Quote Reply
Re: [RedRum] Question about template parsing In reply to
I have quite an ersion of LinkSQL 1.X and my parse sub doesn't support the <%else%> qualifier. Is there a mod that includes this?
Quote Reply
Re: [phoule] Question about template parsing In reply to
Sorry I edited my post just after making it...I was thinking of Links SQL 2+ Blush

What actually happens with that code you tried?

Last edited by:

RedRum: Nov 11, 2001, 9:27 AM
Quote Reply
Re: [phoule] Question about template parsing In reply to
Paul is correct...you cannot use lt or gt (or <>) for text string comparisons. These will work for numerical strings.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [RedRum] Question about template parsing In reply to
Well I just looked at the Template.pm file for LinksNG, and I'm impressed, I want it, but can't upgrade the whole shebang too many other mods.

Has anyone successfully converted to the Template.pm for LinksSQL 2 to function with LinkSQL1.x?


PS: Wow it's been a longtime since I've been over at these here forums and I'm WAY impressed with the speedy replies, thanks soo much guys!

Last edited by:

phoule: Nov 11, 2001, 9:35 AM
Quote Reply
Re: [RedRum] Question about template parsing In reply to
It print outs what you see here:

A link won't help bvecause you have to be logged in and have made posts on the board...

But it prints out that all items regardless of the links cost is available for purchase.

Last edited by:

phoule: Nov 11, 2001, 9:46 AM
Quote Reply
Re: [phoule] Question about template parsing In reply to
Ah well I just had to make my HTML_Templates.pm a bit messier, added in some code to do the check in there and then pass the variable that needed to be output. Though it would have been nice to do it in the template.
Quote Reply
Re: [phoule] Question about template parsing In reply to
Hi phoule,

I did successfully upgrade the template. I don't know what you're version looks like and mine is chalk full of mods, but this is what I did and it was quite simple.

In DB_Utils.pm commented out the following lines:

# $TEMPLATE->clear_vars;
# $TEMPLATE->load_template ($tpl, $string) or die ("Can't load template. Reason: $Links::Template::error");
# $TEMPLATE->load_vars ($vars) or die ("Can't load variables. Reason: $Links::Template::error");
# my $output = $TEMPLATE->parse ($tpl) or die ("Can't parse template. Reason: $Links::Template::error");

and added this line instead:

my $output = GT::Template->parse ( $tpl, $vars, $opts ) or die ("Can't parse template. Reason: $Links::Template::error");

Then copied the whole GT directory from the new version(I doubt it's all needed - Just needed to get it working)

That was it. It doesn't provide access to the globals.txt feature as in Links SQL 2.x, but it does provide access to the the if, else, elsif <%set x=something%> add to existing values and so one. Quite nifty and worth the time to do it.