|
From: Chris W. <ch...@cw...> - 2002-02-12 13:07:38
|
On Tue, 2002-02-12 at 07:53, Tho...@be... wrote:
> Yes I read about it.
>
> I tried like this :
>
> In my handler called 'Nips.pm':
>
> sub MY_SEARCH_FIELDS { return qw( ipnr dnsname comment
> nips_media.ipnr nips_media.rid) }
> sub MY_SEARCH_TABLE_LINKS { return ( nips_media => [ 'ipnr' ] ) }
This should either be a scalar or a two/three-item array reference. So
you might try:
sub MY_SEARCH_TABLE_LINKS {
return { nips_media => [ 'ipnr', 'ipnr' ] ) };
}
Assuming that the two tables have the field 'ipnr' in common.
> in my listing template:
>
> <td align="center"><font size="-1">[% nips_media.rid %] </font></td>
>
> <td align="center"><font size="-1">[% nips.rid %] </font></td>
> <td align="center"><font size="-1">[% nips_media.ipnr %] </font></td>
>
> but none of the fields are displayed :-(
The actions we're discussing here are only for searching, not display.
For display you'll have to use the normal SPOPS relationship stuff. For
example, if we had 'person' and 'address' objects, we might configure:
sub MY_SEARCH_FIELDS { return qw( first_name last_name address.city ) }
So we can search for people by their first and last names, plus the city
of one of their addresses.
For linking, we'd setup:
sub MY_SEARCH_TABLE_LINKS {
return { address => [ 'person_id', 'person_id' ] };
}
But when we ran the search, we'd only get Person objects back. If we
wanted to find the primary address of one of these persons, we'd do
something like:
[% WHILE ( person = iterator.get_next ) %]
[% address = person.primary_address -%]
...
[% END %]
Where 'primary_address()' is a method we've defined in the Person
object.
Hope that makes sense
Chris
--
Chris Winters (ch...@cw...)
Building enterprise-capable snack solutions since 1988.
|