Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: Can’t Use Low Replace on CSM {content} Tag
Status | Resolved |
Add-on / Version | Custom System Messages 2.5 |
Severity | Trivial |
EE Version | 2.6.1 |
Kristen Grote
Sep 05, 2013I’m using Custom System Messages, Mo’ Variables, and HTTP Header to output a JSON-formatted error template if the template is requested with ajax:
{!-- if the template is requested with Ajax, return JSON data. Otherwise, display a normal page --}
{if ajax}
{exp:http_header content_type='application/json'}
{
"success": {if error == 1}false{if:else}true{/if},
"heading": "{heading}",
"message": "{content}"
}
{/if}
{if not_ajax}
{embed='_global/document_head' page_title='{heading}'}
<body class="single">
{header}
<article class="bizness">
<header>
<h1>{heading}</h1>
<p> </header><br />
{content}<br />
{link}<br /></p>
</article>
<p> {footer}<br />
{global_scripts}<br />
{document_foot}<br />
{/if}
jQuery returns an error, however, because CSM outputs line breaks after list items inside the {content} tag.
I tried wrapping the {content} tag in Low Replace tags:
{
"success": {if error == 1}false{if:else}true{/if},
"heading": "{heading}",
"message": "{exp:low_replace find='NEWLINE'}{content}{/exp:low_replace}"
}
but that has had no effect, the line breaks are still there. Anything I can do to get this working?
BoldMinded (Brian)
Did you try the change I sent yesterday? Update line 413 of the ext file to this:
KMGDEV
I did. It didn’t appear to work because I believe that section of code is for if you have “Enable ajax responses?” enabled in the settings, which I don’t because it’s not officially supported.
BoldMinded (Brian)
Oh, well go ahead and turn on that setting. Since you’re using your own template to show the response its OK. I have that warning in there b/c some forms don’t send a JSON response at all, thus causing it to break, but you’re making up the JSON response.
KMGDEV
OK, I enabled the ajax setting, but it looks like CSM is bypassing the custom error template and just sending back its own JSON response.
BoldMinded (Brian)
Oh, duh. Remove the above code change and try this instead.
line 335 add:
https://www.evernote.com/shard/s9/sh/5cd7bc43-a3c5-4110-a807-0b3f8b13ff10/8a0386c28f9d0c66b05652dbdf8aaa11
KMGDEV
That did it!
Is that something that will be included on a future release, or will I need to maintain it going forward?
BoldMinded (Brian)
Sweet! Yes, its already committed and will be in the next release, whenever that will be.
KMGDEV
Awesome! Thanks Brian.