[wellwell-devel] [wellwell] Add variable for database table name used by [category-path] tag.
Stefan Hornburg
wellwell-devel at rt.icdevgroup.org
Thu Oct 11 08:27:06 UTC 2012
commit 35cd7fe7abcfd246ed3a3acd0e46bfde80ce0f5c
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date: Thu Oct 11 10:26:36 2012 +0200
Add variable for database table name used by [category-path] tag.
code/category_path.tag | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/code/category_path.tag b/code/category_path.tag
index db5cd3b..d7730d7 100644
--- a/code/category_path.tag
+++ b/code/category_path.tag
@@ -3,15 +3,17 @@ UserTag category_path AddAttr
UserTag category_path Routine <<EOR
sub {
my ($code, $opt) = @_;
- my ($parent, @path, $joiner);
+ my ($parent, @path, $joiner, $table);
return () unless $code;
- $Tag->perl({tables => 'categories'});
+ $table = $Variable->{CATEGORY_TABLE} || 'categories';
+
+ $Tag->perl({tables => $table});
$path[0] = $code;
- while ($parent = $Db{categories}->field($code, 'parent')) {
+ while ($parent = $Db{$table}->field($code, 'parent')) {
unshift(@path, $parent);
$code = $parent;
@@ -23,7 +25,7 @@ sub {
my @names;
for (@path) {
- push(@names, $Db{categories}->field($_, 'name'));
+ push(@names, $Db{$table}->field($_, 'name'));
}
if (ref $opt->{filter} eq 'ARRAY') {
@@ -43,7 +45,7 @@ sub {
for (my $i = 0; $i < @path; $i++) {
my $uri;
- $uri = $Tag->area($Db{categories}->field($path[$i], 'uri'));
+ $uri = $Tag->area($Db{$table}->field($path[$i], 'uri'));
$names[$i] = qq{<a href="$uri">$names[$i]</a>};
}
More information about the wellwell-devel
mailing list