Gossamer Forum
Home : Products : Gossamer Links : Discussions :

global variables

Quote Reply
global variables
i was wondering if there was a variable for the total number of categories in the database. Also, is there someone that has a comprehensive list of the global variables standard for all installations?

Quote Reply
Re: global variables In reply to
Hi,

No, but:

sub { return $DB->table('Links')->count ( { isValidated => 'Yes' }); }

as a global would do the trick.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: global variables In reply to
Actuallay for category you should use:

sub { return $DB->table('Category')->count; }

The one alex mentioned is for Number of links.

Regards
Abd

http://www.idleb.com
Quote Reply
Re: global variables In reply to
For a list of the globals, just look at the globals on the BUILD menu in the Links Admin.

The other tags available are the CFG tags (from the Settings) and then Links and/or category tags depending on what template you are in.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: global variables In reply to
Hi,

What do you think of a tag you could put on a template like:

<%AVAILABLE_TAGS%>

and it would produce a nice HTML table showing you all the tags currently available and the value. Would this be useful for debugging?

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: global variables In reply to
Very!

Such a simple idea :) Takes a great mind to think of it!


PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Quote Reply
Re: global variables In reply to
Great idea. When will we have it?Wink

Quote Reply
Re: global variables In reply to
Thanks guys, I created a template global called category_total and set it equal to sub { return $DB->table('Category')->count } . Worked great.

Alex, the available tags idea is great as well. Is that something for the next release?

Quote Reply
Re: global variables In reply to
If you add the following code to GT::Template:

Code:
sub dump {
# ---------------------------------------------------------------
# Dumps the variables.
#
my $tags = (ref $_[0] eq 'GT::Template') ? $_[0]->{VARS} : shift;
my $font = 'font face="Tahoma,Arial,Helvetica" size="2"';
my $output = qq~<table border=1 cellpadding=3 cellspacing=0><tr><td colspan=2><$font><b>Available Variables</b></font></td></tr>~;
foreach my $key (sort keys %$tags) {
my $val = GT::CGI->html_escape($tags->{$key});
$val =~ s/\n/<BR>\n/g;
$val =~ s/ / /g;
$output .= qq~<tr><td valign="top"><$font>$key</font></td><td valign="top"><font face="Courier,fixedsys">$val</font></td></tr>~;
}
$output .= qq~</table>~;
}
and then put <%GT::Template::dump%> anywhere on your template it will dump the current tags available.

Let me know what you think,

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: global variables In reply to
Ok that sounds great, but i am kinda of slow..
Is GT::Template: the same as template.pm?
If it is that did not work for me an error says: Sub Dump not found in GT::Template: ?

Any suggestions

thanks
AARON

Quote Reply
Re: global variables In reply to
In Reply To:
error says: Sub Dump not found in GT::Template:
Hi, did you name the sub 'dump' oder 'Dump'?
<%GT::Template::dump%> is case sensitive, I think.

Andreas


--------------------------------------------
http://www.archaeologie-online.de
Quote Reply
Re: global variables In reply to
Yes GT::Template.pm is similar to a path.

GT is the name of the directory and so if you look inside that directory you will see Template.pm which is the file you need to edit.

For example if Alex has said Links::Plugins::Plugin.pm

Then you would find the plugin.pm file in the following location.. /Links/Plugins/Plugin.pm

Paul Wilson.
http://www.wiredon.net/gt/
Coming soon => www.perlmad.com
Quote Reply
Re: global variables In reply to
Hi,

Digger has it right, make sure you use <%GT::Template::dump%>.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: global variables In reply to
So, I am really slow

In which template do I post this code? <%GT::Template::dump%>

I'd like to be able to create a link in the admin so I can see it from there easily. How would I do that?

Quote Reply
Re: global variables In reply to
Evoir, I haven't tried any of the admin templates, but it's worked in all of the "default" templates I've tried... i.e. /admin/templates/default/link.html, etc.

In other words, paste it into any template for which you want to see available tags... some templates have different tags available than others.

--

Matt Glaspie