Re: Passing variables to a [%.. %]

Jason Galea <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CABGOMYaDC2YasqoZhuzsTQ9M2ibFdwEj=vfEeZY0zkQ+E9aZYw@mail.gmail.com>
[% query = 'SELECT * FROM page_tb WHERE  (status  = 2 AND page_code = "
_ data.page_name + '" AND sitename = "' _ data.sitename _" ) ORDER BY
sitename' %]

[% FOREACH link = DBI.query( query ) %]

              [% site      = link.sitename        %]
                [% PageName  = link.view_name %]
                [% Record_id = link.record_id  %]
                [% body      = link.body %]
      [% END %]

that should work for you. Please not, though, the query should really be
executed in your Perl code and only the resulting list passed in to the
template..

cheers,

J

On Mon, Jan 16, 2012 at 4:58 AM, <[email protected]> wrote:

> > On 15 Jan 2012, at 06:38, "[email protected]"
> > <[email protected]> wrote:
> >
> >> Hi
> >>
> >>
> >>      [%# embed(data.page_top_view,['-PAGE_TITLE','$PageName',]) %]
> >>    [% embed(data.page_top_view,['-PAGE_TITLE',[%link.viewname%]) %]
> >
> > I don't think you need [% ... %] around link.viewname do you?
> >
> >
> You are right this is because of the limitation of ttml to not be able to
> nest[% ... %]
>
> I did manage to get the above code to work by changing the ' to ".
>
> Passing variblles into [% ... %] is a on going problem for me.
>
> a keyone is
>
> [% pagecode = data.page_name %] picked up from the url
> [% sitename = data.sitename %]
>  [% FOREACH link = DBI.query("SELECT * FROM page_tb
>                                  WHERE  (status  = 2 AND
>                                         page_code = "$pagecode" AND
>                                         sitename = "$sitename" )
>                                  ORDER BY sitename
>                                  ")%]
>               [% site      = link.sitename        %]
>                 [% PageName  = link.view_name %]
>                 [% Record_id = link.record_id  %]
>                 [% body      = link.body %]
>       [% END %]
> This dose not work. How can I do this? I suppose I could drop to [%
> RAWPerl%]. Any suggestions would be appreciated.
>
> Thanks
> shanta
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.