Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Declare global scalars?

Quote Reply
Declare global scalars?
In the old flatfile version of DBMan, you could declare global variables like:

$small_font = 'font face="verdana, arial, helvetica" size="2";

How do you perform the same action in the new version of DB SQL? I'm using version 2.0.3, and I'd like to edit the templates using as many scalars as possible to keep the code modular.
Quote Reply
Re: [Halito] Declare global scalars? In reply to
You can add this easily to the globals by going to Admin >> Templates and add a new one like :

small_font => 'font face="verdana, arial, helvetica" size="2";

Then you can have a new tag <%small_font%> in your templates.




Quote Reply
Re: [jean] Declare global scalars? In reply to
Thanks, Jean. You're right. I figured this one out once I found the well-written explanation in the Templates.pm file. Maybe it's because I'm used to DBMan, but I'm still reluctant to use the web interface to define anything. Instead, I edited the template files individually.

As you point out, you can define a variable at the beginning of any HTML template by using the set command.

<%set small_font = '<font face="verdana, arial, helvetica" size="1">'%>

Then you can use <%small_font%> anywhere in the template you want your small font to appear.

I took it one step further by creating a new file called globals.html in the same directory as all the other template files. The file contains only set definitions for things like commonly used fonts, background colors and table attributes. Then, I refer to the file with <%include globals.html%> at the top of each of my template files.

It's taking a while to get used to DBSQL after spending so much time with DBMan, but I hope to learn it. By the way, thanks to everyone who writes in this excellent forum. I hope more people contribute to this DBSQL forum over time because it's still pretty quiet in here.