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

I have a richtext area and like to pull this from a json. My problem are double quotes in the text, they give me errors and I can't seem to find how to replace them with single quotes.

Code: Select all

<cms:editable name='content' label='content' desc='write here something' order='2' type='richtext' toolbar='full' no_xss_check='1'></cms:editable>

// text in richtext <p class="html">test</p>
//                          <p>line 2</p>

//json incl. remove multiple lines
<cms:content_type "application/json"/>
[<cms:pages masterpage='pages.php' id='17'>
<cms:set rtext="<cms:php>
    echo(str_replace( \"\r\n\", ' ', \"<cms:show content/>\" ));
</cms:php>" />
               
{"pagetitle":"<cms:addslashes><cms:show k_page_title/></cms:addslashes>",
"content":"<cms:addslashes><cms:show rtext/></cms:addslashes>"
}<cms:if "<cms:not k_paginated_bottom/>">,</cms:if>
</cms:pages>
]

// the ajax- json response for the content

[ { "content": "<p class="html">test</p> <p>line 2</p>"  } ]



I tried to use the same logic as I used to remove multiple lines without any result.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Hi,

There is no need to replace the double-quotes with single-quotes - the standard approach is to escape the the double quotes.
The <cms:addslashes> you are using does precisely that.

I tried the following -
Code: Select all
<cms:capture into='rtext'>
<p class="html">test</p>
<p>line 2</p>
</cms:capture>

<cms:addslashes><cms:show rtext/></cms:addslashes>

and this is the output I received -
Code: Select all
<p class=\"html\">test</p>
<p>line 2</p>

As you can see, the double-quotes have been escaped (i.e. prefixed with a slash).

I am not sure why your output does not match mine,
Please try outputting the contents (raw from editable-region, after removing the newlines, after addslashing) outside the JS code for debugging purpose and see (doing a view-source) as the data changes. Perhaps that would yield a clue.

If you need my help, feel free t PM me the FTP/Couch access creds to your server and I'll give it a look.
hi kk,

thanks for the quick reply

If I have those two lines my error message is:

"content":"<br />
<b>Parse error</b>: syntax error, unexpected 'html' (T_STRING) in <b>/usr/local/zend/apache2/htdocs/CouchCMS-Snippets/couch/tags.php(2934) : eval()'d code</b> on line <b>1</b><br />"
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
I'll have to take a look first-hand at the problem.
Please PM me the access creds. Thanks.
Hi,

I could solve the syntax error somehow :D .. but still have one issue left with ckeditor.
Somehow the editor has a problem with single quotes when I use them in the source mode.

when I type :
Code: Select all
<p class='this'></p>

then when I switch to the normal mode ckeditor changes single quotes to double quotes
Code: Select all
<p class="this"></p>


Is there any way to solve this?
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
5 posts Page 1 of 1
cron