Forum

Thread tagged as: Problem, Addons, Events

HTML tags visible when using textarea and perch_events_custom();

The required field eventDescHTML in the Event App is a textarea. When I view an event listing using the Basic Calendar Listing that's included with the example files everything looks fine. However, when I view a listing using perch_events_custom(), HTML tags are visible in the browser:

Basic Calendar Listing: 'This is an event description'

perch_events_custom(): '<p>This is an event description</p>'

This only happens when a textarea is used in combination with perch_events_custom().

Here is my eventDescHTML tag:

<perch:events id="eventDescHTML" type="textarea" textile="true" editor="markitup" encode="false" />

Here is how I'm calling the template:

<?php       
    perch_events_custom(array(
          'filter'   => 'eventSlug',
          'match'    => 'eq',
          'value'    => perch_get('s'),
          'template' => 'event_detail.html'
    ));
?>

Thank you

Matt Sanchez

Matt Sanchez 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show us your diagnostics?

HEALTH CHECK

Perch is up to date
PHP 5.6.10 is up to date
MySQL 5.5.42 is up to date
Image processing available
SUMMARY INFORMATION

Perch: 2.8.17, PHP: 5.6.10, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.17), assets (2.8.17), categories (2.8.17), perch_events (1.9.2), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_events' );
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/matthewsanchez/Dropbox/narf-local/perch
PERCH_CORE: /Users/matthewsanchez/Dropbox/narf-local/perch/core
PERCH_RESFILEPATH: /Users/matthewsanchez/Dropbox/narf-local/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
Resource folder writeable: Yes
HTTP_HOST: localhost:8888
DOCUMENT_ROOT: /Users/matthewsanchez/Dropbox/narf-local
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is that template tag from event_detail.html ?

<perch:events id="eventDescHTML" type="textarea" textile="true" editor="markitup" encode="false" />

(above) It's the default tag that's in event.html in the Events App folder. I copied event.html into perch/templates/events to add additional tags, but I haven't modified eventDescHTML.

In event_detail.html, where I've reused the tag, It looks like this:

<perch:events id="eventDescHTML" />
Drew McLellan

Drew McLellan 2638 points
Perch Support

You're missing the type attribute from the tag in event_detail.html.

<perch:events id="eventDescHTML" type="textarea" />

I had type="textarea" on there before and it still didn't fix the problem. I also tried type="text" and that didn't work either.

However, I did find that adding encode="false" on the tag in event_detail.html finally prevented the HTML from being encoded. So, the tag in event_detail.html looks like this now:

<perch:events id="eventDescHTML" type="textarea" encode="false" />

encode="false" was already set on the tag in event.html but for some reason it wasn't having any effect.

The remaining problem is that neither Markdown or Textile syntax is working. When I set textile="true" or markdown="true", the Markitup editor will insert the correct syntax but it won't produce the desired result in HTML.

Here's what it looks like in the editor: editor

Result in browser: browser

Source code in console: console

It seems like Textile isn't being processed correctly.

Drew McLellan

Drew McLellan 2638 points
Perch Support

In Textile you need to leave a line between block level elements.

h2. This is a heading

This is a paragraph

h3. This is another heading

That fixed it! I'd never used Textile before and in my haste to fix the problem I didn't look over the documentation as much as I should have.

So, it looks like the actual problem was not having encode="false" on eventDescHTML when it was reused in my custom template.

Thanks for all your help, Drew!