Hi I'm new here, and also new to Umbraco. I was wondering how to make Umbraco not Render my HTML tags in case a field is empty. Let me make an example.
You can also use some jQuery code to remove empty tags. So you don't have to care about these things on the templates or macros. If you want I can give you some sample code (have to search for it in my installations)
You could use the insertTextBefore and insertTextAfter attributes on umbraco:item. These will only be rendered when teaser has a value. see the example below. Make sure you html encode them or insert via the dialog box insert item in Umbraco
remove HTML tags
Hi I'm new here, and also new to Umbraco. I was wondering how to make Umbraco not Render my HTML tags in case a field is empty. Let me make an example.
Here I have an Umbraco field which renderes.
But if the field in Umbraco is empty, the browser of cause render
I can use this code instead, and the p tag will not render, but the code gets more messy.
I know that I could just use XSLT instead with ....if empty...bla bla
But is there a smarter way to write my code??
Thanks
You can also use some jQuery code to remove empty tags. So you don't have to care about these things on the templates or macros. If you want I can give you some sample code (have to search for it in my installations)
Thomas
Hi,
You could use the insertTextBefore and insertTextAfter attributes on umbraco:item. These will only be rendered when teaser has a value. see the example below. Make sure you html encode them or insert via the dialog box insert item in Umbraco
Hope this helps you,
Richard
Example got messed up
<umbraco:Item field="teaser" insertTextBefore="<p>" insertTextAfter="</p>" runat="server"></umbraco:Item>
if you have included jQuery this should do it:
This code removes all empty p tags from the DOM, but you can alos remove all empty tags by
hth,
Thomas
@thomas: I think removing empty tags should be done on server, not on the client.
Agree, only another option if you are tired of typing too much (insertBeforeText...)
;-)
You can create custom http module or handler, which remove empty tags.
But insertTextBefore and after is good enough for me :-)
thank you.. I will try the jQuery, and also just stick to the imsert before and after code..
Hi
I got help for this link. It is Nice to imliment
I think your problem will be slove using this link
http://our.umbraco.org/wiki/how-tos/customizing-the-wysiwyg-rich-text-editor-%28tinymce%29/allow-any-markup-in-the-tinymce-editor
Thanks
Muhammad Hussain
is working on a reply...