[ic] variables

JT Justman jt at airdelights.com
Thu Jul 28 16:33:39 EDT 2005

Webmaster Grandfather Clocks Plus wrote:
> Okay this should be easy, but I don't know enough about Interchange or Perl.
> I'm just trying to make a basic variable that I can put into some html code,
> this is what I'm trying to do:
> [perl]
> $site = "icdevgroup";
> return $site;
> [/perl]
> <html>
> <a href="www.$site.org">ICDEVGROUP.ORG</a>
> </html>
> I can't get this to work, anyone have any idea on how I should go about
> this. Sorry for the basic question. 
> Thanks,
> Brian

Hi, Brian. Maybe I can help you get on the right track.

Variables that you define within a [perl] tag only exist within that
tag. Whatever you 'return' will be printed wherever you insert the tag.
'$site' is perl's way of referring to a variable; it doesn't mean a
thing to IC, which only deals with IC tags like [scratch].

If you just want to store a variable and use it anywhere, you want to
set a scratch variable using [tmp] or [set] and retrieve it with
[scratch]. To do what you tried in your example:

[tmp site]icdevgroup[/set]
<a href="www.[scratch site].org">ICDEVGROUP.ORG</a>

You can set scratch variables from inside [perl] tags, and you can store
the output of a [perl] tag in a scratch variable - depending on your
needs. There is a pretty good section in the Template Guide about
working with Perl.

Props for diving right in to this complicated system, but you have a
little basic learning to do before you do any advanced modifications. My
suggestion: if you plan on doing anything with IC, learn a little Perl -
buy a book or google up a tutorial. Learn more about interchange by
reading the docs and looking at the code already in your catalog. Learn
by example, take other people's code and modify it, and you will come to
understand how IC and Perl work together.


More information about the interchange-users mailing list