Forum for discussing general topics related to Couch.
10 posts Page 1 of 1
It has probably been asked and answered before... I did search for it but could not find it so here goes my question:

On a normal page of our website which is in the structure under index.php (non-repeatable) we are mentioning some e-mail addresses of our sports club. These e-mail addresses were recently abused by external forces. So, we want to use cloak_email on them. Can we and if yes, how can we use cms: tags like cms:cloak_email on a normal page?
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
By 'normal' page, I assume you mean pages of the site which are not Couch managed.
If that assumption is correct, the answer is no because for any <cms: tag to execute it would require Couch's runtime to be managing the page (we do that, as you already know, by adding the two PHP statements to the physical file).
Thanks KK, that's what I thought but hoped would not be ;-) And so in fact I could read your answer also as: turn it into a couch managed page and you can. I will look into that ! Thanks for the quick response, as ever.
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
Can we and if yes, how can we use cms: tags like cms:cloak_email on a normal page?

And so in fact I could read your answer also as: turn it into a couch managed page and you can.


  1. We can load anything to regular HTML pages from Couch-managed templates by JS - <cms:tags> are executed in a couch-managed template and result placed where necessary (ajax).
  2. Normal HTML page may be renamed to *.php and have a PHP injection <?php include('my-couch-managed-template.php') ?>
  3. Normal HTML page may have a script loaded as a separate file which is a couch-managed template with a tag <cms:content_type value='text/javascript' />
  4. maybe more ideas
  5. Edit: do not expose emails and therefore skip the part where emails need be cloaked. Instead use keywords like 'john-doe-mailbox'. Contact form can be submitted to a couch-managed template and processed there, where keyword would be resolved to email (which is stored in backend).

There are more solutions at our disposal other than blindly declare everything a couch managed template. At least I'd like to explore more options in my work. @KK doen't tell you what to do :) It is easy though to make things managed by Couch and brings a lot of flexibility for new websites, however if it is not possible in your long established project, I'd like to think there are options.
Thanks trendoman, for your input and good ideas. Indeed, I resolved to leaving the page as is and created a different contact form for each mailbox. So interested people can still contact us through the form, but the bad guys cannot obtain our emails so easily anymore.

Another problem, which seems related, is: how can I use HTML5 tags like <button> in a "normal" page in Couch? Couch "translates" the HTML tags it does not recognize to normal text, therefore HTML5 tags are not possible. Is there a resolution for this?
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
Couch "translates" the HTML tags it does not recognize to normal text, therefore HTML5 tags are not possible.

Let's see your code, if possible.
What I would want to insert in the "normal" page in Couch (it's a page, not a managed template) is this:

Code: Select all
<button type="button" class="btn btn-outline-primary">Contact</button>


This results in the button text being shown on the page as normal text:

<button type="button" class="btn btn-outline-primary">Contact</button>

In the source of the page, when viewed from Couch, it looks like this after being saved:

Code: Select all
<p>&lt;button type=&quot;button&quot; class=&quot;btn btn-outline-primary&quot;&gt;Contact&lt;/button&gt;</p>


However, when working on this answer I found the answer already, at least the answer to this particular "button" problem. Because when I use button classes on the A element, it works:

Code: Select all
<a class="btn btn-primary" href="#" role="button">Contact</a>


This correctly shows my button with a working link.

So this particular problem is solved, however, in general I would still be interested to know if and how this could be resolved?
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
I think you are trying to post the HTML of the button through an editable region from the backend, right?

Couch, by default, treats all user inputs with suspicion and allows only a relatively safer subset of HTML tags through - rest are 'sanitized' (by converting them to plain text). I that would explain to you what you observed.

That said. it is not considered good practice to allow (or even expect) users to input HTML through the backend. They are supposed to input only data and it should be your (i.e. the developer/designer) job to format that data and output the desired HTML.

For example, in your case -
Code: Select all
<button type="button" class="btn btn-outline-primary">Contact</button>

it would be inordinate to expect the end-user to input the correct classes. Morever, she could later inadvertently mess those classes while editing and destroy the markup on the frontend.

The recommended way would be, for example, to accept only the button type (via a dropdown) and title (via a text region) from the backend and then output the correct HTML yourself on the frontend e.g.
Code: Select all
<button type="<cms:show my_button_type' />" class="btn btn-outline-primary"><cms:show my_button_text /></button>

That makes your code so much more 'bullet proof'.

Hope this helps.
Hi KK, thanks for your reply. In our case, I am the web designer, webmaster and (for most content) web author, all in one for our small sports club. Normally, yeah I cannot expect a regular editor of the site to know all this. In your example, of using selectable button types, that could only be done on templates. The page I am speaking about is not a template, it's just a regular page on the site which exposes buttons to the contact forms. But it's food for thought -- I will not always stay the all-in-one web designer, webmaster and web author for this sports club, so I will start making some edits like you are suggesting to make the site future proof.

[EDIT] To see the page I am speaking about, this is it: https://www.twirlteam-surprise.nl/vereniging/over-ons/
"I have never tried that before, so I think I should definitely be able to do that" - Pippi Longstocking
Hi.
I get your point. I suggest you use 'shortcodes' for outputting any arbitrary HTML - https://docs.couchcms.com/miscellaneous/shortcodes.html

Hope it helps.
10 posts Page 1 of 1