stripping out empty tags from empty fields

Is Coranto not working properly for you? Here's where to ask for support help; for best results, follow these steps:
  • - Check your core/addon documentation for possible solutions
  • - Search these forums for similar problems that have already been solved
  • - If you're still stumped, check out THIS TOPIC, and post your question in this forum!!

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

stripping out empty tags from empty fields

Postby Stoneage » Wed Feb 28, 2007 6:44 pm

I'm attempting to strip out empty tags when there is no user input in specific fields. Left empty, the tags are published on the page, and there is a large gap where the empty tags are.

The two tags I'm trying to strip out are:

<p class="style1"></p>
<img src="http://www.domain.com/pix/" alt="" />

I've not been able to do this successfully with Search & Replace (although Search & Replace is working with other tag replacements).

Is there a conditional snippet of Perl code I could insert in the style that would take care of this?

I've searched the old and new forum, but can't find this topic anywhere. I'm hoping someone here has the answer.

Thanks in advance.
Deborah
Stoneage
 
Posts: 52
Joined: Fri Jan 12, 2007 1:07 am
Location: Maine, USA

Postby SrNupsen » Wed Feb 28, 2007 7:41 pm

You should use <If> statements in your style. Using your own tags, one example might be:

Code: Select all
<If: Field: CustomField_something>
<p class="style1"><Field: CustomField_something></p>
</If>


and...

Code: Select all
<If: Field: CustomField_image>
<img src="<Field: CustomField_image>" alt="" />
</If>


This way, your tags will only be output if the field actually contains something.
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway

Postby Stoneage » Wed Feb 28, 2007 8:05 pm

That worked perfectly! And I now have an understanding of how the <If> statement works. You've really helped me a lot!

Thank you.

:D
Deborah
Stoneage
 
Posts: 52
Joined: Fri Jan 12, 2007 1:07 am
Location: Maine, USA

Postby SrNupsen » Wed Feb 28, 2007 8:43 pm

My pleasure :) I'm still amazed when I discover new and powerful possibilities with Coranto, and I've used it for 5 years :wink:
-----------------------------------------------------------------------------------------------------
Coranto is free software. I am available for custom work or troubleshooting.

http://www.sundaune.no - transkripsjon, webdesign, nettsider, tekstbyrå
http://www.vagbladet.no - satire, politikk, kultur, sport, nettavis
-----------------------------------------------------------------------------------------------------
SrNupsen
 
Posts: 2229
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway


Return to Troubleshooting

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron