Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Phantom Paragraph Tags


Reply


5 Posts   2190 Views

Avatar
redking

43 Posts

15 August 2008 at 6:14am

Hi,

When viewing my published site, I am finding three pairs of phantom paragraph tags <p></p> in one particular section of the page. They are actually appearing in the presentation of the page (see attached image), not just in the source code. I've scoured the template for that page and can't find where these tags are coming from. I've also checked to make sure that there are no hard paragraph breaks in the CMS that could be causing it. Has anyone experienced this before?
I've isolated it to one section of code in my template (see below), but am complete boggled as to where these tags are coming from. Anyone have any insight?

Thanks!

The snippet of code in which the tags are coming from:

<!-- Begin Blue Content Area -->
            <div id="contentBandBlue">
               <div id="contentBlue">
                  $BlueContent
                  
                  <!-- Begin Left Column -->
                  <div id="leftColumnHome">
                     $LeftColContent
                  </div>
                  <!-- End Left Column -->
                  
                  <!-- Begin Middle Column -->
                  <div id="midColumn">
                     $MidColContent
                  </div>
                  <!-- End Middle Column -->
                  
                  <!-- Begin Right Column -->
                  <div id="rightColumnHome">
                     $RightColContent
                  </div>
                  <!-- End Right Column -->
                  
               </div>
            </div>
            <!-- End Blue Content Area -->

Avatar
redking

43 Posts

15 August 2008 at 6:16am

Here's the image. I forgot to upload it in the previous post.

Avatar
redking

43 Posts

15 August 2008 at 7:08am

I just tried adding content via the CMS in the area where these mysterious tags are appearing, and it won't render it. I just displays the actual code. This makes me think I have an unclosed tag somewhere, but I can't seem to find one. This is so odd...

Avatar
redking

43 Posts

15 August 2008 at 7:15am

Just in case, here's what the pagetype looks like:

<?php
/**
* Defines the HomePage page type
*/

class HomePage extends Page {

   static $db = array(
   'BlueContent' => 'Text',
   'LeftColContent' => 'Text',
   'MidColContent' => 'Text',
   'RightColContent' => 'Text'
   );

   function getCMSFields() {
   $fields = parent::getCMSFields();
   
   $fields->addFieldToTab('Root.Content.Blue', new HtmlEditorField('BlueContent', 'Blue Conent'));
   $fields->addFieldToTab('Root.Content.LeftCol', new HtmlEditorField('LeftColContent', 'Left Col Conent'));
   $fields->addFieldToTab('Root.Content.MidCol', new HtmlEditorField('MidColContent', 'Mid Col Conent'));
   $fields->addFieldToTab('Root.Content.RightCol', new HtmlEditorField('RightColContent', 'Right Col Conent'));
   
   return $fields;
   }
   
   static $has_one = array(
   );

static $icon = "tutorial/images/treeicons/home";

}

class HomePage_Controller extends Page_Controller {
   
}
?>

Avatar
Willr

Forum Moderator, 5513 Posts

15 August 2008 at 1:03pm

The problem is you have defined your database fields as Text fields. This is plain text (eg not going to be rendered as HTML) yet you use HTMLEditorFields to edit it which will allow HTML but because it is a text field in the database thats what it outputs it as.

Silverstripe should warn you about this bug - make sure you have error_reporting() on. But the fix is simple, change your Database fields to HTMLText or change the cms boxs to TextareaFields() rather then HTMLEditors if you only intend on using plain text