[Catalyst] Relationship layout

Will Smith willbelair at yahoo.com
Wed Oct 5 22:02:47 CEST 2005


I try to do the right way but looks like i way too off the right track. So I just loop the result using 2 stashes
    $c->stash->{artist} = music::M::CDBI::Artist->search_like(name=>'%beatle%');
    $c->stash->{art} = music::M::CDBI::Artist->cds;
 
then on the template:
 
[% WHILE (mycd = artist.next) %]
[% mycd.name %] has: 
[% WHILE (cd = art.next) %]
[% IF mycd.artistid == cd.artistid %]
<br>
<li>
[% cd.title %]
</li>
[% END %]
[% END %]
[% END %]

I still get the result that I want, but it does not the has_many means.

Matt S Trout <dbix-class at trout.me.uk> wrote:
On Wed, Oct 05, 2005 at 08:09:42PM +0200, Andreas Marienborg wrote:
> If you have set the $c->stash->{artist} correctly, you should be able 
> to do the following in your template:
> 
> [% artist. %]
> 
> if you use Template Toolkit
> 
> for instance:
> 
> [% artist.name %]
> 
> if artist has a field "name".

And if artist has_many cds, then

[% FOREACH cd = artist.cds %]

might also be useful :)

You really want to read the Template Toolkit POD carefully about the way
it handles arrays and hashes and how the various loop directives etc. work
- I've never found a need to use EVAL_PERL provided I refreshed my memory
from the POD beforehand if I was trying to do something complex.

-- 
Matt S Trout Specialists in perl consulting, web development, and
Technical Director UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

_______________________________________________
Catalyst mailing list
Catalyst at lists.rawmode.org
http://lists.rawmode.org/mailman/listinfo/catalyst

		
---------------------------------
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20051005/37fb58b9/attachment.htm


More information about the Catalyst mailing list