CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • HTML In Views 2 Event View
Pages: [1]

Author Topic: HTML In Views 2 Event View  (Read 1777 times)

denverdataman

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 2
    • Denver DataMan Website
  • CiviCRM version: Several
  • CMS version: Drupal 6/7
HTML In Views 2 Event View
June 12, 2009, 09:41:11 pm
When I add HTML to the event description it prints the HTML in the view rather than rendering the HTML. I don’t see a way to change. Here is an example  http://www.ccdconline.org/drupal/upcoming_events Any suggestions?

Thanks,
Steve


Steve Kessler
Owner and Lead Consultant of Denver DataMan

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: HTML In Views 2 Event View
June 12, 2009, 10:06:21 pm

would be great if you can investigate and figure out the code changes required to let views know that description is potentially an HTML field. If you do so, please file an issue along with the patch

most of views2 is contributed code, so our ability to debug/fix things is a bit limited

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

bchoc

  • Guest
Re: HTML In Views 2 Event View
June 12, 2009, 10:45:09 pm
Looking at the code on that page, it seems that the symbols in the HTML are being escaped.

e.g.:
Code: [Select]
<blockquote>
<p style="text-align: center;"><span style="color: rgb(51, 102, 255);">Testing what this will do when I put more HTML in here.<img

Is it Civi or Drupal that is converting < and > to &lt; and &gt; and so forth?  I don't know.

denverdataman

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 2
    • Denver DataMan Website
  • CiviCRM version: Several
  • CMS version: Drupal 6/7
Re: HTML In Views 2 Event View
June 14, 2009, 07:32:51 am
Quote from: bchoc on June 12, 2009, 10:45:09 pm
Looking at the code on that page, it seems that the symbols in the HTML are being escaped.

Is it Civi or Drupal that is converting < and > to &lt; and &gt; and so forth?  I don't know.

It must be views because it looks fine in Civi. http://www.ccdconline.org/drupal/civicrm/event/info?reset=1&id=1
Steve Kessler
Owner and Lead Consultant of Denver DataMan

joemaine

  • I post occasionally
  • **
  • Posts: 114
  • Karma: 3
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.14
  • MySQL version: 5.1
  • PHP version: 5.2
Re: HTML In Views 2 Event View
June 28, 2009, 09:15:38 am
Is it possible for the theme setting in the view to correct the output of the HTML code?

Could this also be an issue with API Changes since 2.2.3
http://api.drupal.org/api/function/l

If the HTML option from CiviEvent is passed as false, can it be changed in a custom theme setting view file (ex. views-view-field--viewname--fieldname.tpl.php). ...and what would the code in the file be?

Would another potential be to do a str_replace in the .tpl.php file for &lt;, &gt;, &nbsp;, etc? ...and what would the code in that file be?
« Last Edit: June 28, 2009, 11:59:04 am by joemaine »
--
Joe

joemaine

  • I post occasionally
  • **
  • Posts: 114
  • Karma: 3
  • CiviCRM version: 4.1
  • CMS version: Drupal 7.14
  • MySQL version: 5.1
  • PHP version: 5.2
Re: HTML In Views 2 Event View
June 28, 2009, 01:05:55 pm
Here's a piece of bad code you can add to a custom view template for a given field (ex. views-view-field--viewname--fieldname.tpl.php).


<?php
$output=str_replace('&lt;/', '</', $output);
?>
<?php
$output=str_replace('&lt;', '<', $output);
?>
<?php
$output=str_replace('&gt;', '>', $output);
?>
<?php
$output=str_replace('&nbsp;', ' ', $output);
?>
<?php
$output=str_replace('&quot;', '"', $output);
?>
<?php
print $output;
 ?>


If you go down this path, be careful of the order and it might be best that you only create a custom template for individual fields, not for the whole view.

I know there has to be a better solution; this will make the view 'work', but it's a total hack. Could someone create a decent array from my mess?
« Last Edit: June 28, 2009, 01:24:03 pm by joemaine »
--
Joe

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: HTML In Views 2 Event View
July 17, 2012, 06:31:36 pm
I realize that this is an ancient post but in case someone is looking for a better way to deal with this than just making a views template with some replace rules, have a look at this bug report for the same issue in Views3 (LINK).

The file in question is found in civiCRM 3.x in Drupal 6 sites at: sites/all/modules/civicrm/drupal/modules/views/civicrm.views.inc

The area to look at is around line 1602 for the 'EVENT SUMMARY' and 'EVENT DESCRIPTION' handlers
« Last Edit: July 17, 2012, 06:41:04 pm by awasson »
My CiviCRM Extension Workshop: https://github.com/awasson

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • HTML In Views 2 Event View

This forum was archived on 2017-11-26.