var — access local (catalog) and global Interchange variables
Attribute | Pos. | Req. | Default | Description |
---|---|---|---|---|
name | Yes | Yes | Name of the Interchange variable to display. | |
global | Yes | Empty value only looks for a catalog variable. Value of
1 looks
only for a global variable. Value of 2 looks for the
catalog variable
with the fallback to global, if local one is not defined. |
||
filter | None. | filter to apply. | ||
interpolate | 1 | interpolate output? | ||
hide | 0 | Hide the tag return value? |
This tag gives access to Interchange global or catalog variables.
Direct access to variables (using the syntax) is
faster, so you should only use this tag where the direct access is
impossible.
Here's the equivalence list:
[var
==
VAR
]__
VAR
__
[var
==
VAR
1]@@
VAR
@@
[var
==
VAR
2]@_
VAR
_@
Example: Direct access equivalence example
Note that the following two lines are identical in effect:
[image src="[var IMAGE_DIR]/items/[cgi item_id]" border=0 extra="id='item_img'"] [image src="/items/[cgi item_id]" border=0 extra="id='item_img'"]
Interchange 5.9.0:
Source: code/UserTag/var.tag
Lines: 34
# Copyright 2002-2007 Interchange Development Group and others # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the LICENSE file for details. # # $Id: var.tag,v 1.12 2007-03-30 23:40:57 pajamian Exp $ UserTag var Order name global filter UserTag var Interpolate 1 UserTag var Version $Revision: 1.12 $ UserTag var Routine <<EOR sub { my ($key, $global, $filter) = @_; my $value; if ($global and $global != 2) { $value = $Global::Variable->{$key}; } elsif ($Vend::Session->{logged_in} and defined $Vend::Cfg->{Member}{$key}) { $value = $Vend::Cfg->{Member}{$key}; } else { $value = ( $::Pragma->{dynamic_variables} ? Vend::Interpolate::dynamic_var($key) : $::Variable->{$key} ); $value ||= $Global::Variable->{$key} if $global; } $value = filter_value($filter, $value, $key) if $filter; return $value; } EOR