Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hey,

I've encountered few problems related to nicedit, which doesn't display nicely (contrary to it's name). While it's easy to fix, I still can't seem to grasp basic things around it.

I'll give a quick overlook on how it works:

So, Client enters all the needed settings ->

Code: Select all
<cms:repeatable name='contacts' >
   <cms:editable name='contact_name' label='Vārds' maxlength='100' type='nicedit' />
   <cms:editable name='contact_job_lv' label='Amats_lv' maxlength='100' type='nicedit' />
   <cms:editable name='contact_job_en' label='Amats_en' maxlength='100' type='nicedit' />
   <cms:editable name='contact_job_ru' label='Amats_ru' maxlength='100' type='nicedit' />
   <cms:editable name='contact_phone' label='Telefona numurs' maxlength='100' type='text' />
   <cms:editable name='contact_email' label='E-pasts' maxlength='100' type='text' />
</cms:repeatable>


Which then gets displayed on the site:

Code: Select all
<cms:pages masterpage='globals.php'>
         <cms:show_repeatable 'contacts' >
         <div class="grid-6">
         <li>

         <cms:if "<cms:not_empty contact_name />" >
            <i class="icon-user icon-large" style="color:chocolate"></i>  <b><cms:show contact_name /></b>
         </cms:if>

         <cms:if "<cms:not_empty contact_job_ru />" >
            <i class="icon-briefcase icon-large" style="color:darkolivegreen"></i>  <cms:show contact_job_ru />
         </cms:if>

         <cms:if "<cms:not_empty contact_phone />" >
            <i class="icon-phone-sign icon-large" style="color:darkslateblue"></i>  <cms:show contact_phone />
         </cms:if>

         <cms:if "<cms:not_empty contact_email />" >
             <i class="icon-envelope icon-large" style="color:goldenrod"></i>  <cms:show contact_email />
         </cms:if>

         </li>
      </div>
   </cms:show_repeatable>
</cms:pages>


Well, I tried to put everything for Russian version, so I could display how it works and everything works great.

Image

Well, here I have the question. Why it is making automatic </br> tags? I've never put them in the code. I would believe it was because there's a space between the code? Of course, it makes everything look even better.


Ok, so I give this to the client, and say to him, well - you can put other variables "contact_job_lv" and "contact_job_en" here.

Well - he just went ahead and did that, using ctrl-c -> ctrl-v from Word. End results was a mess - it's been fixed for now - but using the same code, the lines were out order, the font was significantly bigger - the problem was - it added somewhat random [span] tags in html, and formatted text in his own way.

While it's kinda fixed now - it still does some html formating on it's own - how can I clear it, without deleting the whole row?

HTML Code:

How it should be:

Code: Select all
<div class="grid-6">
   <li>
   
      <i class="icon-user icon-large" style="color:chocolate"></i>  <b>Arvis Vingris<br /></b>
   

   
      <i class="icon-briefcase icon-large" style="color:darkolivegreen"></i>  Valdes Priekšsēdētājs<br />
   

   
      <i class="icon-phone-sign icon-large" style="color:darkslateblue"></i>  29199234
   

   
       <i class="icon-envelope icon-large" style="color:goldenrod"></i>  arvis@rdr.lv
   

   </li>
</div>


How it is in fixed version:


Code: Select all
<div class="grid-6">
   <li>
                     
      <i class="icon-user icon-large" style="color:chocolate"></i>  <b>Raivis Vingris<br /></b>
                        
      <i class="icon-briefcase icon-large" style="color:darkolivegreen"></i><span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-style: normal;">Ražošanas daļas vadītājs</span><br />
                        
      <i class="icon-phone-sign icon-large" style="color:darkslateblue"></i>  25652157
                     
       <i class="icon-envelope icon-large" style="color:goldenrod"></i>  raivis@rdr.lv
                     
   </li>
</div>


So, to put it all together -> Here are my key questions..

1. How are </br> tags created?
2. How to remove formatting, if copied from other sources, more precisely, clear ALL formatting aka [span] tags?

(using basic text was a option - and it was used, but it was really squished together, meaning it would be hard to read/edit);



Thanks.
1. BR tags are created by NicEditor; they are intentional and necessary. If you don't want any accompanying HTML tags, use a 'textarea' type editable region.

2. Please see http://www.couchcms.com/forum/viewtopic.php?f=4&t=7068. In summary, paste the text first into a text editor to remove any included formatting.
@lolsteamroller
Adding to what @cheesypoof pointed out - in my opinion you do not need 'nicedit' at all.
Simple 'text' would work just fine so the client only inputs plain text and your template controls all enclosing formatting e.g. if the <BR> looks good you can add it in the markup itself.
Code: Select all
<i class="icon-user icon-large" style="color:chocolate"></i>  <b><cms:show contact_name /><BR></b>

In case the input of some field might span more than one line, you can use 'textarea' instead. While outputting, wrap the variable in a cms:nl2br (http://www.couchcms.com/docs/tags-reference/nl2br.html) tag so that every newline gets converted into a <BR> automatically -
<cms:nl2br><cms:show contact_job_ru /></cms:nl2br>
Hi,

I was just searching for a solution to my similar problem. In my case using a text or textarea just doesn't quite cut it. My client needs <i> and <b> also.
I was poking around in the Nicedit PHP.

isn't this the part where one could define the allowed tags upon pasting?
Code: Select all
$orig_data = $this->data;
            if( $this->trust_mode==0 ){
                // if value submitted from front-end form, input is untrusted and so only a limited subset of HTML tags will be allowed
                $allowed_tags = '<a><br><strong><b><em><i><u><blockquote><pre><code><ul><ol><li><del>';
                $this->data = trim( $FUNCS->cleanXSS(strip_tags($post_val, $allowed_tags), 1) );
@Saskia,
The code that you posted is security related where content posted from the front-end (i.e. via Databound Forms) is allowed to have only a subset of HTML.

For entry via admin-panel, although you can define which buttons are available in nicedit (see 'buttons' parameter - http://www.couchcms.com/docs/tags-refer ... cedit.html), the user can still copy content from somewhere and paste it into the editor.

For this you have to ask them to either paste the contents into the 'source' panel of nicedit or first paste in any text editor and then transfer contents into the editor.
Ah ok, Thanks for your explanation :)
6 posts Page 1 of 1