Forum
Markdown fields broken in Perch 2.8.18 when using perch_template()
I have just updated a site to Perch to 2.8.18 and am seeing raw (and broken) HTML tags being displayed in Markdown-based regions.
The problem only seems to be occurring when using perch_template() to display content. Content displayed with perch_content() renders correctly, and perch_content_custom() is retrieving the data correctly.
(Possibly similar to this problem - https://forum.grabaperch.com/forum/11-21-2015-markdown-not-working-after-2816-update)
Can you help, please?
Template code:
<perch:content id="body" type="textarea" label="Body" markdown="true" editor="markitup" required="true" size="l" />
Section of data retrieved using perch_content_custom():
[body] => <p>Lorem ipsum dolor sit amet, <a href="https://test.com" title="">consectetuer adipiscing</a> elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
Output from perch_template() (using same template as the one used to capture the data). Notice how the data is wrapped in a <p> tag, and the <a> is completely broken:
<p><p>Lorem ipsum dolor sit amet, <a href=”<a href="https://test.com">https://test.com</a>” title=”“>consectetuer adipiscing</a> elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p></p>
Diagnostics:
Perch: 2.8.18, PHP: 5.4.22, MySQL: mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $, with PDO
Server OS: WINNT, apache2handler
Installed apps: content (2.8.18), assets (2.8.18), categories (2.8.18), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms' );
PERCH_LOGINPATH: /perch
PERCH_PATH: C:\xampp\htdocs\terencedonovan\perch
PERCH_CORE: C:\xampp\htdocs\terencedonovan\perch\core
PERCH_RESFILEPATH: C:\xampp\htdocs\terencedonovan\perch\resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 256M, Total max file upload: 100M
Resource folder writeable: Yes
HTTP_HOST: terencedonovan
DOCUMENT_ROOT: C:/xampp/htdocs/terencedonovan
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Are you passing already encoded HTML back through the template? If so, you need to add
encode="false"
else it will be encoded twice.Hi Drew,
I've added
encode="false"
into the template tag (as below), but it doesn't fix the problem.The content was being displayed correctly until I upgraded from 2.8.13 to 2.8.18.
Any other ideas?
Can you show me the code you're using? All our unit tests are passing, so there's obviously some subtly to it.
OK, here goes...
This is the main PHP doc. The content for this page is stored in a "multiple" region, and only one of the region items is displayed at once. Rewrite rules determine which one, using the slug held in $_GET['arg'].
If the slug is valid, the corresponding content is then passed to perch_template() to be output.
The content is entered using 'content/article.html' - the same template as perch_template() is using to output it. Here's the template (including the encode tag):
Thanks!
Hi Drew,
Have you been able to get to the bottom of this problem?
Thanks, Jon
Not yet - it's still on my list.
Here's some further information that might be handy:
This is the content captured by the perch_content_custom() call. It's exactly as I'd expect:
And here's an example of the content that is being passed to the perch_template() call (in the $page variable):
Thanks in advance for your help.
I'm experiencing the same issue.
I'm pulling in some collection items
Shuffling the array and and taking the top two...
and then using perch_template() to output the html...
and
This results in
<p>
tags being output around the markdown fields.I'm using 2.8.20.
Caleb
please raise a new thread for your own issue including your Diagnostic Report and template - thanks!
Apologies. I'll raise it again in a few days with the proper info.