Forum for discussing general topics related to Couch.
7 posts Page 1 of 1
I need to cms:show content which was entered via a 'richtext' field. This is the code:

Code: Select all
<a href="<cms:show k_page_link />">
   <h2><cms:show k_page_title /></h2>
   <p><cms:show description /></p>
   <div class="meta">
      <small>Update: <b><cms:date k_page_date format='M j, Y h:i a' /></b> by <b><cms:show author /></b></small>
   </div>
</a>

The problem occurs when "description" contains a link itself, since then there's a link nested in a link. It is both semantically incorrect and impossible to style properly.

Given the situation, is there a way of stripping all HTML added in a richtext field when pulling that data with cms:show? Similar to how it's possible to format k_page_date? So, perhaps something like <cms:show description format='plaintext'>?
Hi Davort,

If you don't want HTML formatting, any specific reason why you are not using an editable region of type 'textarea' instead?

TIP: While using 'textarea', the new lines can be converted into BR using the cms:nl2br tag
Code: Select all
<cms:nl2br><cms:show description /></cms:nl2br>
Hi KK, we had that in the beginning, however we're using that same content in another place on the site and there we actually benefit from being able to format content (lists, links...) in a more complex manner.

Unfortunately, 'textarea' could not fulfill our needs in that regard, so we switched to 'richtext' instead.
OK, I get it now :)

I think we can use the cms:excerpt (http://www.couchcms.com/docs/tags-refer ... cerpt.html) tag here.
It is used to create an 'excerpt' of contents but before doing that it also strips off HTML tags.
We can use that 'side-effect' for our purpose.
Code: Select all
<cms:excerpt count='1000' ><cms:show description /></cms:excerpt>

Does this help?
Oh yes, that will probably help! Will check it out and let you know. Thanks! :)
Worked like a charm! Thank you so much :)
You are welcome :)
7 posts Page 1 of 1