-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 10:20 PM +0100 3/24/01, Gerald Richter wrote:
>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
If they were all the same, that would be fine, but usually it's more
complicated. What you want to avoid is
having
firstname middleinitial lastname
addr1
addr2
state, city postacode country
turning into something like
John . Smith
1 Main Street.
, US
Not that pretty at all.
Using ? : doesn't work well because of the $escmode issue. I just
wanted to make sure I wasn't missing something obvious. Before I
started proposing Embperl extensions.
I don't have any great ideas here. The only thing I've come up with
so far is that you could have a variation on [+ +] which
conditionally affected the line. Let's call it [? ?].
<br>[? $foo ?],
would result in either
<br>something,
or no line at all. I think that that is the most compact solution
that would cover 90% of the cases. You would have to think about
what happens if two of those exist on the same line. Both must
return defined values?
Note that in the following example it doesn't fix everything, but it
cleans up quite a bit.
This
<b>Contact</b>
<br><a href="mailto:[+ $domains[$row]{email} +]">
[+ $domains[$row]{first_name} +] [+ $domains[$row]{last_name} +]
</a>
[$ if ($domains[$row]{organization_name}) $]<br><a
href="?organization_name=[+ $domains[$row]{organization_name} +]">[+
$domains[$row]{organization_name} +]</a>[$ endif $]
[$ if ($domains[$row]{address1}) $]<br>[+ $domains[$row]{address1}
+][$ endif $]
[$ if ($domains[$row]{address2}) $]<br>[+ $domains[$row]{address2}
+][$ endif $]
[$ if ($domains[$row]{address3}) $]<br>[+ $domains[$row]{address3}
+][$ endif $]
[$ if ($domains[$row]{city}) $]<br>[+ $domains[$row]{city} +],[$ endif $]
[+ $domains[$row]{state} +]
[+ $domains[$row]{postal_code} +]
[+ $domains[$row]{country} +]
[$ if ($domains[$row]{phone} || $domains[$row]{fax}) $] <br> [$ endif $]
[$ if ($domains[$row]{phone}) $][+ $domains[$row]{phone} +] (V)[$
endif $][$ if ($domains[$row]{fax}) $], [+ $domains[$row]{fax} +] (F)
[$endif $]
becomes
<b>Contact</b>
<br><a href="mailto:[+ $domains[$row]{email} +]">
[+ $domains[$row]{first_name} +] [+ $domains[$row]{last_name} +]
</a>
<br><a href="?organization_name=[+ $domains[$row]{organization_name}
+]">[? $domains[$row]{organization_name} ?]</a>
<br>[? $domains[$row]{address1} ?]
<br>[? $domains[$row]{address2} ?]
<br>[? $domains[$row]{address3} ?]
<br>[? $domains[$row]{city} ?],
[+ $domains[$row]{state} +]
[+ $domains[$row]{postal_code} +]
[+ $domains[$row]{country} +]
[$ if ($domains[$row]{phone} || $domains[$row]{fax}) $] <br> [$ endif $]
[$ if ($domains[$row]{phone}) $][+ $domains[$row]{phone} +] (V)[$
endif $][$ if ($domains[$row]{fax}) $], [+ $domains[$row]{fax} +] (F)
[$endif $]
In the meantime I should at least assign $domains[$row] to a
temporary variable and use that, then at least I get rid of that
duplication.
- --
Kee Hinckley - Somewhere.Com, LLC - Cyberspace Architects
Now Playing - Folk, Rock, odd stuff - http://www.somewhere.com/playlist.cgi
I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBOr18XSZsPfdw+r2CEQL63gCgxQrbdL1IJ3BgrGCg2PoRFBDplREAoP5f
hWht3Lp2X8GidWp4R7DqLV3L
=PwhA
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]