[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] creating a temporary page variable


Quoting Jeff Dafoe (suppressed):
> Hello,
> 
>     This is one of those "it sounds dumb to me" questions but I have
> reviewed the docs a trillion times on this and haven't come up with an
> answer.  From what I understand, set and tmp both create variables in the
> session record.  Is there any way to create and access a temporary variable
> that is scoped to just the single template iteration that never gets saved
> in the session?
> 

[tmp], [seti], and [set] (and [tmpn] in 4.9) are all in $Scratch, but
if you do:

 [tmp some_scratch] something [/tmp]

it goes away after the current page.

If you are using embedded Perl, you can use any variable name except
$item, $s, and $q (legacy items, won't ever go away because of discounts)
and it will be carried around in the page and never get saved in the session.

So, to summarize:

[calc]
        # This goes away at the end of this calc tag
        my $thing = "won't see after this tag is done";

        # This can be accessed in another calc tag or perl tag or even
        # a UserTag
        $other_thing = 'something that will persist to next calc';

[/calc]

[/calc]

[calc]
        my $out = "This should be empty: $thing";
        $out .= '<br>';
        $out .= "This should be set: $other_thing";
        $out .= '<br>';
        return $out;
[/calc]

[calc]
        # $Scratch->{somevar}, flagged to be deleted before session is
        # written
        $Tag->tmp('somevar');
        $Scratch->{somevar} = 'a very long string' x 100_000;
        return;
[/calc]

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <suppressed>

Fast, reliable, cheap.  Pick two and we'll talk.  -- unknown
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.