Gossamer Forum
Home : Products : Links 2.0 : Customization :

Enhanced Template.pm

(Page 1 of 2)
> >
Quote Reply
Enhanced Template.pm
Hi,

I've enhanced the Template.pm module to allow comparisions! This should allow you to do things like:

<%if Rating > '9'%> This is a top notch link!<%endif%>

or:

<%if Votes = '0'%> Hey! No one has voted for this link yet! <%endif%>

Give it a try, it's in the Resources section. Let me know if there are any problems.

Cheers,

Alex
Quote Reply
Re: Enhanced Template.pm In reply to
This is a good addition, much props to you. Now maybe people can put text on seperate categories. Stuff like that.
Quote Reply
Re: Enhanced Template.pm In reply to
Thanks Alex. That is wonderful!

It will cut down a lot of coding in the site_html_templates.pl file!

Smile Kudos!

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Enhanced Template.pm In reply to
Hi!
It seems, as

Code:
my $end = $self->{'end'} &#0124; &#0124; quotemeta('%>');
is missing!

Tiggr

------------------
visit http://larp-welt.de/
the resource for german live roleplaying



Quote Reply
Re: Enhanced Template.pm In reply to
Hi, it's me again! ;o)

Why isn't this
Code:
<A HREF="<%db_cgi_url%>/review.cgi?ID=<%ID%>">Anmerkungen<%if Reviews > '0'%> (<%Reviews%> )<%endif%></A>
working????? (It always prints the (...)-Part, even Reviews is zero!

Tiggr



------------------
visit http://larp-welt.de/
the resource for german live roleplaying



Quote Reply
Re: Enhanced Template.pm In reply to
Try putting the codes in this order:

<%if Reviews > '0'%>
<A HREF="<%db_cgi_url%>/review.cgi?ID=<%ID%>">Anmerkungen</a>
( <%Reviews%> )
<%endif%>

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Enhanced Template.pm In reply to
Sigh, the < and > disappeared on me. Please re apply the patch and you should be fine.

Cheers,

Alex
Quote Reply
Re: Enhanced Template.pm In reply to
Have you found an answer to my problem yet, I'm litrbf@aol.com, It keeps on saying that everytime i add it again. I replaced my db_utils.pl since i never did anything to it before. I don't get it because it says it can't compilate because of the line that requires template.pm, which i guess there must be something wrong with.
-------------------------------------------
I think it may be working now, i replaced template.pm.

[This message has been edited by Bmxer (edited September 08, 1999).]
Quote Reply
Re: Enhanced Template.pm In reply to
Really nice! I just downloaded the NEW Template.pm codes. Works wonderfully! I was able to replace the Amazon Rating Image mod with fewer codes in the link.html file.

I am attempting to replace the 3 Graphics Mod (since it is not working very well) with the new template tags.

I have tried the following:

Code:
<%if Date = '2'>
<img src="new1.gif">
<%endif%>
<%if Date = '3'>
<img src="new2.gif">
<%endif%>
<$if Date = '5'>
<img src="new3.gif">
<%endif%>
<$if Date = '10'>
<img src="new4.gif">
<%endif%>

It doesn't work. Also, I would like to find a way to mirror these type of codes in the sub site_html_print_cat routine in site_html_templates.pl file, so that the NEW graphics will be the same for categories and links.

Any ideas?

Thanks.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Enhanced Template.pm In reply to
I don't think it was written right,
have you tried this
Code:
<%if Date = '2'%>
<img src="new1.gif">
<%endif%>
<%if Date = '3'%>
<img src="new2.gif">
<%endif%>
<%if Date = '5'%>
<img src="new3.gif">
<%endif%>
<%if Date = '10'%>
<img src="new4.gif">
<%endif%>
Quote Reply
Re: Enhanced Template.pm In reply to
Yes, I did use the end % in the tags. Sorry about posting the wrong codes. Smile

Thanks, BMxer.

Hmm....

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Enhanced Template.pm In reply to
Elliot,

Try adding:

Date is <%Date%>

at the end, and let me know what it says.

Cheers,

Alex
Quote Reply
Re: Enhanced Template.pm In reply to
Hi!
Yes, you (Eliot) are absolutly right:
Code:
<%if Reviews > '0'%>
<A HREF="<%db_cgi_url%>/review.cgi?ID=<%ID%>">Anmerkungen</a>
( <%Reviews%> )
<%endif%>
works fine! (Now I can rate this mod with 10!)

Bye and thanks
Tiggr

------------------
visit http://larp-welt.de/
the resource for german live roleplaying



Quote Reply
Re: Enhanced Template.pm In reply to
Tiggr,

Glad it worked.

Alex,

Sorry...I am a bit confused, I guess. I put the codes Date is <%Date%> at the end of the codes I wrote in the link.html file.

Code:
<%if Date = '1'%>
<img src="/images/wwwvl/graphics/new1.gif" border="0" width=34 heigh
t=1 alt="Today" align="absmiddle">
<%endif%>
<%if Date = '2'%>
<img src="/images/wwwvl/graphics/new1.gif" border="0" width=34 heigh
t=1 alt="2 days" align="absmiddle">
<%endif%>
<%if Date = '3'%>
<img src="/images/wwwvl/graphics/new1.gif" border="0" width=34 heigh
t=1 alt="3 days" align="absmiddle">
<%endif%>
<%if Date = '5'%>
<img src="/images/wwwvl/graphics/new3.gif" border="0" width=34 heigh
t=1 alt="5 days" align="absmiddle">
<%endif%>
<%if Date = '7'%>
<img src="/images/wwwvl/graphics/new3.gif" border="0" width=34 heigh
t=1 alt="7 days" align="absmiddle">
<%endif%>
<%if Date = '10'%>
<img src="/images/wwwvl/graphics/new7.gif" border="0" width=34 heigh
t=1 alt="10 days" align="absmiddle">
<%endif%>
<%if Date = '14'%>
<img src="/images/wwwvl/graphics/new7.gif" border="0" width=34 heigh
t=1 alt="14 days" align="absmiddle">
<%endif%>
Date is <%Date%>

Here is the result:

Code:
Science's Next Wave Date is 6-Sep-1999
(Added: 6-Sep-1999 Hits: 0 Votes: 0)
Provides marketing tips, job hunting news, and much more. An ideal resource for anthropologists with advanced degrees who are seeking to get into academia or work in the private sector.
[ Rate this Site ] [ Recommend Link ]
[ Report Dead Link ] [ Spider this Site ] [ Translate ]


You will notice that the date just prints out.

Hmm....

Regards,




------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 09, 1999).]

[This message has been edited by Eliot (edited September 09, 1999).]
Quote Reply
Re: Enhanced Template.pm In reply to
I read this thread, but i still dont understand, does this work for everything ?

Thanx
Quote Reply
Re: Enhanced Template.pm In reply to
Eliot,

Ok, I see the problem. You are doing:

if Date = 10
print this
endif

However, Date is an actual date '6-Sep-1999', so it will never equal 10. I think what you want to do is in site_html_templates.pl, figure out how many days old the link is, then do something like:

<%if DaysOld > '7'%>
<img src=/new14.gif>
<%endif%>

<%if DaysOld < '8'%>
<%if DaysOld > '3'%>
<img src=/new7.gif>
<%endif%>
<%endif%>

<%if DaysOld < '4'%>
<%if DaysOld > '1'%>
<img src=/new2.gif>
<%endif%>
<%endif%>

<%if DaysOld = '1'%>
<img src ="/new1.gif>
<%endif%>

Kind of ugly, but there is no else statement. =)

Cheers,

Alex
Quote Reply
Re: Enhanced Template.pm In reply to
Does this work for Links SQL ?
Quote Reply
Re: Enhanced Template.pm In reply to
 
Quote:
Does this work for Links SQL ?

Yes, you can apply this patch to template.pm. It will be standard in future versions.

Cheers,

Alex
Quote Reply
Re: Enhanced Template.pm In reply to
Alex,
You know in the search results where you have the <%if category_results%> <%...results%> <%endif%>, I put that and yet the text i use in it still comes up, on every page too. The categories don't if there are none, which is in search.cgi. I tried <%if cat_hits == 0%> also with '' around 0. Could this be where i put the if tags?
------------------------------------
Nevermind,
I work with cgi, but in html, this took some getting use to, i see i said if it equals 0 to print the thing which was what i didn't want, so i put > and it works.

[This message has been edited by Bmxer (edited September 09, 1999).]
Quote Reply
Re: Enhanced Template.pm In reply to
Couldn't this:

Code:
<%if DaysOld > '7'%>
<img src=/new14.gif>
<%endif%>

<%if DaysOld < '8'%>
<%if DaysOld > '3'%>
<img src=/new7.gif>
<%endif%>
<%endif%>

<%if DaysOld < '4'%>
<%if DaysOld > '1'%>
<img src=/new2.gif>
<%endif%>
<%endif%>

<%if DaysOld = '1'%>
<img src ="/new1.gif>
<%endif%>

be simplified to:

Code:
<%if DaysOld < '15'%>
<img src ="/new<%DaysOld%>.gif>
<%endif%>

The cost being a few extra images added to the images directory, but the amount of template processing reduced significantly?
Quote Reply
Re: Enhanced Template.pm In reply to
No. That actually does not work, pugdog. When I tried the less than and greater than comparisions (>< ), I got multiple new images next to links.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Enhanced Template.pm In reply to
Eliot ...

The piece of code (3 lines) I gave you is only evaluated ONCE.... it first determines if the date is less than 15 (ie: 0-14) Then it allows the <img> tag to be evaluated with the value of <%DaysOld%>.

I don't see how you can get multiple image tags next to the link.

If you do get multiple image tags, then it has to be a problem with the parser.

I'm not nesting the tags, or anything -- it's just those three lines that decides if the file is newer than your cut off, and if it is, then picks the proper graphic.

(I haven't installed this mod yet so I don't know if it works, but it should... the penalty is making dupliates of the graphics one for each date 0-14)


[This message has been edited by pugdog (edited September 13, 1999).]
Quote Reply
Re: Enhanced Template.pm In reply to
Im trying to make an Editor's Choice feature.

i added a fields called it ( Choice )

then added that in (sub site_html_link)
in sit_html_templates.pl

when i tried :
<%if Choice = 'Yes'%>Editor's Choice<%endif%>
in link.html
it doesnt work,
but when i just have <%Choice%>
i get the value of it , which is ( Yes )

can someone tell me where im going wrong?

Thank you
Quote Reply
Re: Enhanced Template.pm In reply to
Try using eq rather than =. Typically = is for numerical values and eq is for alpha values.

So the codes should look like the following:

Code:
<%if Choice eq 'Yes'%>
Editor's Choice
<%endif%>

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Enhanced Template.pm In reply to
"=" is neither numeric or alphanumeric..

"==" numeric

"eq" alphanumeric

= just does things like

$you = $nothim;

jerry
> >