dynamic_variables — dynamically update configuration directives from files and databases
This pragma enables configuration directives (Variables,
most notably) to be dynamically updated from system files and databases.
It only makes sense to use this in combination with the
DirConfig or VariableDatabase directives,
so check their reference pages for more information.
Example: Enable dynamic_variables pragma catalog-wide
Put the following in your catalog.cfg:
Pragma dynamic_variables
Interchange 5.7.0 (2/2 contexts shown):
Source: code/UserTag/var.tag
Line 25 (context shows lines 15-29)
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;
Source: lib/Vend/Interpolate.pm (rev. 2.310 from Sat Dec 6 00:01:23 2008)
Line 616 (context shows lines 606-620 in vars_and_comments():598)
$::Pragma->{$1} = (length($2) ? $2 : 1), ''/ige;
undef $Vend::PageInit unless $::Pragma->{init_page};
if(defined $Vend::PageInit and ! $Vend::PageInit++) {
Vend::Dispatch::run_macro($::Pragma->{init_page}, $html);
}
# Substitute in Variable values
$$html =~ s/$Gvar/$Global::Variable->{$1}/g;
if($::Pragma->{dynamic_variables}) {
$$html =~ s/$Evar/dynamic_var($1) || $Global::Variable->{$1}/ge
and
$$html =~ s/$Evar/dynamic_var($1) || $Global::Variable->{$1}/ge;
$$html =~ s/$Cvar/dynamic_var($1)/ge;