Re: Access to has_a data from Template?

[prev] [thread] [next] [Date index for 2004/09/16]

From: Clayton L. Scott
Subject: Re: Access to has_a data from Template?
Date: 21:25 on 16 Sep 2004
On Thu, 16 Sep 2004, Edward J. Sabol wrote:

> Jesse Sheidlower wrote:
> > I want my "format" field to be a drop-down list (or, say, a
> > radio_group, or whatever) populated with the values of MyDB::Format.
> >
> > That's it. That's all I want to do. Maybe it's just a TT
> > question but I can't figure out how to get my CDBI data from
> > within TT. Note that this is an "add" form so I won't have a
> > specific book object here.

You should wriote the code to get the dat in you application and then pass
it to TT.

my @formats = MyDB::Format->retrieve_all();

$data{'formats'} = \@formats;

$tt->process(..., \%data, ...);

--template.tt--
[% FOREACH f in formats %]
  [%# do something with each format %]
[% END %]


OR
If you really have to get the data from within TT you'll probably want to
have a look at Template::Plugin::Class
http://search.cpan.org/dist/Template-Plugin-Class/

[%

   USE format = Class('MyDB::Format');
   formats = format.retrieve_all;
%]

[% WHILE f = formats.next %]
  [%# we're running into a problem here with TT iterators
   vs CDBI iterators... hence the while

   [%# do something with each format %]

[% END %]



Clayton

(message missing)

Access to has_a data from Template?
Jesse Sheidlower 11:28 on 16 Sep 2004

Re: Access to has_a data from Template?
Tony Bowden 17:30 on 16 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 17:39 on 16 Sep 2004

Re: Access to has_a data from Template?
Tony Bowden 19:02 on 16 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 19:19 on 16 Sep 2004

Re: Access to has_a data from Template?
Tony Bowden 22:23 on 16 Sep 2004

Re: Access to has_a data from Template?
Charles Bailey 23:31 on 16 Sep 2004

Re: Access to has_a data from Template?
Richard Clamp 19:28 on 22 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 18:09 on 16 Sep 2004

Re: Access to has_a data from Template?
Edward J. Sabol 19:01 on 16 Sep 2004

Re: Access to has_a data from Template?
Clayton L. Scott 21:25 on 16 Sep 2004

Re: Access to has_a data from Template?
Jesse Sheidlower 13:38 on 17 Sep 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52