On 10/31/06, Ash Berlin <[EMAIL PROTECTED]> wrote:
Kevin Old wrote:
> Hello everyone,
>
> I'm trying to use DBIx::Class with HTML::Template and I can't seem to
> get it to work.
>
> Here's how I'm calling DBIC and HTML::Template in my script:
>
> my $tmpl = HTML::Template->new( filename => "single_stories.tmpl",
> die_on_bad_params => 1);
> my @stories = $schema->resultset('Stories')->search( { user_id => 1234 }
> )->all;
>
> if ( $stories ) {
>    $tmpl->param( stories => $stories );
>    print $tmpl->output;
> }
>

Not sure if thats a transposition error,

but dont you want:

if ( [EMAIL PROTECTED] ) {
    $tmpl->param( stories => [EMAIL PROTECTED] );
    print $tmpl->output;
}

Anyway, take a look at the Cookbook, near the end there is a way to
inflate to a hashref, which would do what you want in this case I
suspect. Currently you'll have to write it yourself like in the
cookbook, but by next release it will be part of the dist.

Sorry, that was a transposition error...should have been @stories in
the if statement.

When you say "near the end" this is what I think you're referring too, correct?
http://search.cpan.org/~danieltwc/DBIx-Class-0.07002/lib/DBIx/Class/Manual/Cookbook.pod#___top

So, basically you're telling me to override the inflate_result
subroutine to return what I want?  I don't want that data structure
returned every time I call that result set, just on certain occasions?

Was thinking I might be able to write a Component I could use and
"drop in" when I needed it that would maybe add another function so
that I could return this AoH of results.

Thanks,
Kevin
--
Kevin Old
[EMAIL PROTECTED]

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to