>
> I often find myself with code like this:
>
>                 <br>[+ $set[$row]{organization_name} +]
>                 <br>[+ $set[$row]{address1} +]
>...

Assuming that $set is a DBIx::Recordset object, you can leave out the $row
if it doesn't have changed, e.g.

                 <br>[+ $set[$row]{organization_name} +]
                 <br>[+ $set{address1} +]
                 <br>[+ $set{address2} +]

you can also first get the record it self:

                [- $rec = $set[$row] -]
                 <br>[+ $rec ->  {organization_name} +]
                 <br>[+ $rec -> {address1} +]

>
> But that doesn't deal with missing data, so I have to turn it into:
>
>                 [$ if ($set[$row]{organization_name}) $]<br>[+
$set[$row]{organization_name} +][$ endif $]
>                 [$ if ($set[$row]{address1}) $]<br>[+ $set[$row]{address1}
+][$ endif $]

What about creating a loop:

                [- $rec = $set[$row] -]
                [$foreach $field ('organization_name', 'address1',
'address2') $]
                     [$ if ($data= $rec -> {$field}) $]<br>[+ $data +][$
endif $]
                [$endforeach$]

That's the shortest solution that currently comes to my mind

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     [EMAIL PROTECTED]         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to