Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Problems Adding Template Globals

Quote Reply
Problems Adding Template Globals
Hi All,

I Have added some fields to the User Database which i would like to collect on signup. I;ve changed the template, but when i try and add them to the template globals, it says the update has been successful but doesnt show the new fields.

Any ideas??


Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Problems Adding Template Globals In reply to
I'm not sure what you are doing.

When you add fields to the Users table, those fields should become tags in the templates for any logged in user. If you add a field "Does_Drugs" , the "<%Does_Drugs%> would be a tag in your template.

I don't see where fields are being screened out anywhere in Links.pm, Authenticate.pm or SiteHTML.pm

You don't need to use the template globals for that.

If you are trying to access other fields about a user in a "Links" record, ie: the LinkOwner "User" information in displaying a link to some other user, that is a horse of a different color.

You'd need to create a template global function to look up LinkOwner, grab the information, and return it in field tags that didn't clash with the curent logged in User field tags.

Again, putting <%GT::Template::dump%> at the bottom of your template will show you what tags are available, and help debug your templates.

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Problems Adding Template Globals In reply to
Hi Pugdog,

Let me be more specific...

I want to collect additional information from the user on signup. so i have added 4 fields to the user table. First_Name, Surname, Company_Name Tel_Number.

I've re-sync the tables and added the fields to the sign-up template but all i get is Unknown Tag errors. You can see them here http://www.activesms.co.uk/cgi-bin/lsql/user.cgi?signup_form=1

I Know its going to be something simple!!


Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Problems Adding Template Globals In reply to
I'll bet you set up your form wrong...

<tr>
<td align="right" valign="top"><%body_font%>First Name:</font>
</td>
<td>
<input name="First_Name" value=<%if First_Name%><%First_Name%><%endif%>>
</td>
</tr>



Remember, "tags" are display tags, and if empty, are going to probably generate an error. You need to wrap display tags that might be empty with an <%if%> clause.

On input, a tag will be empty. On display, it _should_ have a value (if "not null")

PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin
Quote Reply
Re: Problems Adding Template Globals In reply to
Hi Pugdog,

Here is the HTML for the signup.txt page

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>

<head>
<title><%site_title%>: User Signup</title>
<link rel=stylesheet href="<%build_images_url%>/default/links.css" type="text/css" title="style sheet">
</head>

<BODY>
<H1><%site_title%>: User Signup</H1><%include header.txt%>
<FORM action="<%db_cgi_url%>/user.cgi" method=post>
<P>To register, please fill out this form completely. A valid email address is
required.</P><%if error%>
<P><STRONG class=error><%error%></STRONG></P><%endif%>
<DIV class=margin>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD vAlign=top align=right>Company Name:</TD>
<TD><INPUT size=50 value="<%Company_Name%>" name=Company_Name</TD></TR> <TR>
<TD vAlign=top align=right>First Name:</TD>
<TD><INPUT size=50 value="<%First_Name%>" name=First_Name></TD></TR> <TR>
<TD vAlign=top align=right>Surname:</TD>
<TD><INPUT size=50 value="<%Surname%>" name=Surname></TD></TR> <TR>
<TD vAlign=top align=right>Telephone Number:</TD>
<TD><INPUT size=50 value="<%Tel_Number%>" name=Tel_Number></TD></TR> <TR>
<TD vAlign=top align=right>Username:</TD>
<TD><INPUT size=50 value="<%Username%>" name=Username></TD></TR>
<TR>
<TD vAlign=top align=right>Password:</TD>
<TD><INPUT size=50 value="<%Password%>" name=Password></TD></TR>
<TR>
<TD vAlign=top align=right>Email:</TD>
<TD><INPUT size=50 value="<%Email%>" name=Email></TD></TR>
<TR>
<TD></TD>
<TD><INPUT type=submit value=Signup name=signup_user></TD></TR></TBODY></TABLE></DIV></FORM><%include
footer.txt%>
</BODY>
</html>
I just copied the fields that already existed!!



Regards

MDJ1
http://www.isee-multimedia.co.uk
Quote Reply
Re: Problems Adding Template Globals In reply to
This is the problem:

value="<%Surname%>"


If the Surname has not been entered, it cant exist. You need to change that to:

value = "<%if Surname%><%Surname%><%endif%>"

Or, if it's _just_ an add form, you can make value=''.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Plugins:http://LinkSQL.com/plugin