Gossamer Forum
Home : Products : Links 2.0 : Customization :

Enhanced Templete Error

Quote Reply
Enhanced Templete Error
Hi All.

When I replace the code (as stated in the Resource Center) to utilize the "Enhanced Templete" feature, I am getting the error:

Code:
CGI ERROR==========================================Error Message : fatal error: exists operator argument is not a HASH element at /home/hans/.html/cgi-bin/links/admin/Template.pm line 114.

What is the problem here?
I know its not line 114!

JbA
Quote Reply
Re: Enhanced Templete Error In reply to
I assume you tried using the codes I gave you after you installed the new codes for the Template.pm file, right?

Did you copy the codes exactly as I posted?
When did you come across this error?
What codes are using that caused this error?

BTW: Line error messages usually show errors surrounding that line. Check the syntax a few lines before and after that line.

Regards,

------------------
Eliot Lee
* Be sure to visit the Resource Center for FAQ's, Modifications and Extra Goodies!!
* Search Forums!
* Say NO to Duplicate Threads. Smile
----------------------













[This message has been edited by Eliot (edited February 17, 2000).]
Quote Reply
Re: Enhanced Templete Error In reply to
Hi Eliot.

Well, after getting your last message, I was totally stoked that it would be that easy!

So, I went on the hunt for the "Enhanced Templete.pm" that you mentioned.

I found a Resource link that (I think Alex posted) that listed instructions to replace the [sub parse] section.

So, I removed what was there and replaced it with what Alex posted. Which is:

Code:
sub parse {
# ---------------------------------------------------------------
# Parses a template.
#
my ($self, $template) = @_;
my $begin = $self->{'begin'} &#0124; &#0124; quotemeta('<%');
my $end = $self->{'end'} &#0124; &#0124; quotemeta('%>');

exists $self->{'templates'}{$template} or ($self->load_template($template) or return undef);
exists $self->{'vars'} or (&error ('NONAMESPACE') and return undef);
$self->{'parsed'}{$template} = '';

my $temp = $self->{'templates'}{$template};

# Parse includes, do this first so that the includes can include
# template tags.
$temp =~ s#$begin\s*include\s*(.+?)\s*$end#
if (exists $self->{'inc'}{$1}) { $self->{'inc'}{$1}; }
else {
if (open (INC, "${$self}{'ROOT'}/$1")) {
$self->{'inc'}{$1} = join ("", <INC> );
close INC;
$self->{'inc'}{$1};
}
else {
"Can't find file: ${$self}{'ROOT'}/$1";
}
}
#goe;

# Now go line by line and strip out the unwanted stuff looking for
# if and ifnot tags.
my @lines = split /\n/, $temp;
$temp = ''; my @go = (1,1); my $depth = 1; my $line = '';

LINE: foreach $line (@lines) {
# Init the previous, variable and more strings.
my ($prev, $var, $neg, $more, $orig, $full_comp, $comp, $val) = ('', '', '', '', '', '', '', '');
my $result = 0;

# Check for if tags.
$line =~ s/((.*?)$begin\s*if(not)?\s+(.+?)(\s+(<|>|lt|gt|eq|=)\s*(.+?))?$end(.*))/
($orig, $prev, $neg, $var, $full_comp, $comp, $val, $more) = ($1, $2, $3, $4, $5, $6, $7, $8);

# We've found an if tag, let's set the depth to see whether we are in print mode or not.
if ($prev !~ m,$begin\s*endif\s*$end,og) {
$go[$depth] and ($temp .= $prev);
if (!$full_comp) {
if ($neg) { ($self->{'vars'}{$var}) ? ($go[++$depth] = 0) : ($go[++$depth] = $go[$depth]) and ""; }
else { ($self->{'vars'}{$var}) ? ($go[++$depth] = $go[$depth]) : ($go[++$depth] = 0) and ""; }
}
else {
$val =~ s,^['"],,; $val =~ s,['"]$,,;
($comp eq 'eq') and ($result = ($self->{'vars'}{$var} eq $val));
($comp eq '==') and ($result = ($self->{'vars'}{$var} == $val));
($comp eq 'lt') and ($result = ($self->{'vars'}{$var} lt $val));
($comp eq 'gt') and ($result = ($self->{'vars'}{$var} gt $val));
($comp eq '>') and ($result = ($self->{'vars'}{$var} > $val));
($comp eq '<') and ($result = ($self->{'vars'}{$var} < $val));
if ($neg) { $result ? ($go[++$depth] = 0) : ($go[++$depth] = $go[$depth]) and ""; }
else { $result ? ($go[++$depth] = $go[$depth]) : ($go[++$depth] = 0) and ""; }
}
}
else {
# Oops, there was an endif tag we missed, set the original line back and keep going.
$more = ''; $orig;
}
/oe;
if ($more) { $line = $more; redo LINE; }

# Check for endif tags.
$line =~ s/(.*?)$begin\s*endif\s*$end(.*)/
($prev, $more) = ($1, $2);
$go[$depth] and ($temp .= $prev);
$go[$depth--] = 1;
"";
/oe;
if ($more) { $line = $more; redo LINE; }

# Add the content..
$go[$depth] and ($temp .= "$line\n");
}

# Replace the special variables, we allow code ref mapping.
$temp =~ s/$begin\s*(.+?)\s*$end/
if (exists $self->{'vars'}{$1}) {
ref ($self->{'vars'}{$1}) eq 'CODE' ?
&{$self->{'vars'}{$1}}($self->{'vars'}) : $self->{'vars'}{$1};
}
else { "Unkown Tag: $1"; }
/goe;

$self->{'parsed'}{$template} = $temp;

return $self->{'parsed'}{$template};
}

Then, I added the commands you gave me to my [links.html] file.

I reuploaded them both.

I then ran the nph-build.cgi and got the previous indicated error message.

It threw the error up right after it created the [index.htm] file.

I looked at the [sub parse] but I'll be darned if I know what the problem is!

Any ideas?

JbA
Quote Reply
Re: Enhanced Templete Error In reply to
You need to replace the original sub parse with the complete sub parse codes located in the Resource Center.

You seem to have a bunch of extraneous codes in the sub parse routine you posted in this Thread...

Hope this helps.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Enhanced Templete Error In reply to
Hi Eliot.

I got it from:
http://www.gossamer-threads.com/...ces/Detailed/26.html
Which is in the Resource/Modication section.

Is it not the right one?

btw... neat new handle!

JbA
Quote Reply
Re: Enhanced Templete Error In reply to
Thanks about the handle...It seems that my other account has been deleted from the system...so I created a new one...

Anyway...yes...that is the one that you need to use.

I really can't understand why it is giving you that error message.

Please post the exact codes you are using in the link.html file.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Enhanced Templete Error In reply to
Ok.


Here is the code
Quote:
<%if ZipMP3 eq 'Zip'%><a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">Download</a><%endif%>

and

Quote:
<%if ZipMP3 eq 'MP3'%><a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">Listen</a><%endif%>

All I did was copy it from your previous post.

I went digging through some old posts last night, and found one other person ask the same question, but there was never an answer for it...

Later.
JbA
Quote Reply
Re: Enhanced Templete Error In reply to
And MP3 and Zip are the string values for the ZipMP3 field, right?

And you have classified this field as a alpha type of field in your links.def file, right?

I don't know if this will make any difference, but try re-naming the ZipMP3 field to ZipMP. The number should not make a difference, but try it anyway...

Also, please provide the EXACT codes you are using for the ZipMP3 field, including the columns in the database definition area, the %add_system_fields hash, and the %db_select_fields hash in your links.def file.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Enhanced Templete Error In reply to
Howdie.


Here is my link.def file:

http://www.4cm.com/download/links.def.txt

Let me know if you need anything in .txt format!

And, of course, thanks for the help!
JbA
Quote Reply
Re: Enhanced Templete Error In reply to
Try changing the following:

Code:
ZipMP3 => [15, 'alpha', 0, 5, 0, 'Zip', ''],

to the following codes:

Code:
ZipMP3 => [15, 'alpha', 0, 5, 0, 'Zip', 'Zip|MP3'],

Then change the following:

Code:
ZipMP3 => 'ZIP,MP3'

to the following:

Code:
ZipMP3 => 'Zip,MP3'

Do you by chance see the errors of your ways?

You have Zip in the default value column in the db_def hash...then you have ZIP as one of the values for the %db_select_fields array.

That, I think, is your main problem.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums

Quote Reply
Re: Enhanced Templete Error In reply to
Eliot,

Hello. Well the problem is fixed.

The one I was using had

Code:
<ul><li>
<!-- SONG TITLE -->
<b>
<%if ZipMP3 eq 'MP3'%>Song Title:<%endif%>
<%if ZipMP3 eq 'Zip'%>Song Title:<%endif%>
<%if ZipMP3 eq 'Must Rename To .MP3'%>Song Title:<%endif%>
<%if ZipMP3 eq 'SHOUTcast'%>Stream Title:<%endif%>
</b><a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a><br>

<!-- BAND NAME -->
<b>
<%if ZipMP3 eq 'MP3'%>Band Name:<%endif%>
<%if ZipMP3 eq 'Zip'%>Band Name:<%endif%>
<%if ZipMP3 eq 'Must Rename To .MP3'%>Band Name:<%endif%>
<%if ZipMP3 eq 'SHOUTcast'%>Stream Description:<%endif%>
</b><%Description%><br>

<!-- RECORD TITLE -->
<b>
<%if ZipMP3 eq 'MP3'%>Record Title:<%endif%>
<%if ZipMP3 eq 'Zip'%>Record Title:<%endif%>
<%if ZipMP3 eq 'Must Rename To .MP3'%>Record Title:<%endif%>
<%if ZipMP3 eq 'SHOUTcast'%>BitRate<%endif%>
</b><%RecordTitle%><br>

<small class="date">(Downloads: <%Hits%> - Rating: <%Rating%> - Votes: <%Votes%> )<br>
[<a href="<%db_cgi_url%>/rate.cgi?ID=<%ID%>">Rate It</a>]
<%if ZipMP3 eq 'MP3'%>[<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">Listen/MP3</a>]<%endif%>
<%if ZipMP3 eq 'Zip'%>[<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">Download</a>]<%endif%>
<%if ZipMP3 eq 'SHOUTcast'%>[<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">Listen/Stream</a>]<%endif%>
<%if ZipMP3 eq 'Must Rename To .MP3'%>[<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>">Download - Must Rename To .MP3</a>]<%endif%>

</ul>

Again, thanks Eliot!

------------------
John B. Abela
Owner, 4CM
www.4cm.com/
support@4cm.com

Presently working on:
www.4cm.com/cmp3/
Finished: www.humbee.com/buzz/




[This message has been edited by Yokhannan (edited February 21, 2000).]

[This message has been edited by Yokhannan (edited February 21, 2000).]
Quote Reply
Re: Enhanced Templete Error In reply to
Glad you figured it out.

One thing that I forgot to suggest was to use = rather then eq. While eq should've worked with both numerical and alpha characters.

The problem with deleting -gt is that you will not be able to do range type conditional if/ifnot tags in your template files.

Regards,

------------------
Eliot Lee....
* Check Resource Center
* Search Forums



[This message has been edited by AnthroRules (edited February 21, 2000).]