[ic] Passing parameters to usertags
Interchange User
interchange-users@icdevgroup.org
Mon May 26 11:24:00 2003
Hi folks,
I'm having some trouble with (what I think is) a very basic question
on a custom usertag. I have the following tag, which I am constructing
to dynamically build a navbar on an IC 4.9.7 site. The problem I am
having is getting parameters passed to the subroutine. I thought if I
wanted to access a section of the web site called "search" under a page
called "database" (where "section" and "page" are just terms I'm using
to describe different parts of my site) I could do something like
[test_nav page=database section=search]
and have the variables $page and $section be accessible to me, but that
doesn't appear to work.
So instead, I started calling my tag with positional parameters, like
so:
[test_nav database search]
This works, sort of. I am able to shift arguments off the @_
variable, but everything after the tag name (eg: "database search")
gets pulled off as one variable, whereas I expected this to come off as
a list. In my subroutine, I thought I could do
my ($page, $section) = @_;
but that doesn't work, and instead I have to do the following:
UserTag test_nav Interpolate
UserTag test_nav Routine <<ENDTEST
sub {
my $nav;
my $page;
my $section;
my $args = shift; # Gets arguments that were passed, as a single
string?
($section, $page) = split / /, $args;
# do stuff with $section and $page...
}
ENDTEST
Is this normal?
Thanks,
Peter