Page 1 of 1

stripping out empty tags from empty fields

PostPosted: Wed Feb 28, 2007 6:44 pm
by Stoneage
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

PostPosted: Wed Feb 28, 2007 7:41 pm
by SrNupsen
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.

PostPosted: Wed Feb 28, 2007 8:05 pm
by Stoneage
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

PostPosted: Wed Feb 28, 2007 8:43 pm
by SrNupsen
My pleasure :) I'm still amazed when I discover new and powerful possibilities with Coranto, and I've used it for 5 years :wink: