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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

SimpleHTMLEditorField doesnt use paragraph tags?


Reply

4 Posts   1745 Views

Avatar
theoldlr

23 September 2010 at 3:18am Community Member, 103 Posts

Maybe this is normal, but the SimpleHTMLEditorField I'm using does not generate p tags. It surrounds the text by divs instead, which makes the text entered in this field look different from everywhere else that the normal tinymce wysiwyg field is used.

Anybody know a work around or a fix for this? Here is how I am defining and using the field in the template:

DataObject

class UsedEquip extends DataObject{

static $db = array (
'Name' => 'Varchar(255)',
'Description' => 'HTMLText',
'Material' => "Enum('Mild Steel,Stainless Steel','Mild Steel')",
'Tanks' => 'Text',
'MaterialHandling' => "Enum('Conveyor,Drum,Monorail','Conveyor')",
'URLSegment' => 'Varchar(255)'
);

static $has_one = array (
'UsedEquipPage' => 'UsedEquipPage',
'Photo' => 'Image'
);

public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name','Name'),
new SimpleHTMLEditorField('Description'),
new DropdownField(
$name = "Material",
$title = "Made From",
$source = singleton('UsedEquip')->dbObject('Material')->enumValues()
),
new TextField('Tanks','No. of Tanks'),
new DropdownField(
$name = "MaterialHandling",
$title = "Material Handling",
$source = singleton('UsedEquip')->dbObject('MaterialHandling')->enumValues()
),
new SimpleImageField('Photo')

);
}
function Thumbnail() {
$Photo = $this->Photo();
if ( $Photo ) {
return $Photo->CMSThumbnail();
} else {
return null;
}
}

public function onBeforeWrite(){
if($this->Name){
$this->URLSegment = SiteTree::GenerateURLSegment($this->Name);
if($object = DataObject::get_one($this->ClassName, "URLSegment='" .$this->URLSegment
."' AND ID !=".$this->ID)){
$this->URLSegment = $this->URLSegment.'-'.$this->ID;
}
// else {
//$this->URLSegment = SiteTree::GenerateURLSegment($this->ClassName.'-'.$this->ID);
//}
parent::onBeforeWrite();
}
}

}

Template Snippet:

<% control IndividualEquip %>

<div id="UsedImage">
$Photo.setWidth(600)
</div>
<div id="Overview" class="typography">
<p>Overview:</p>
<ul>
<li>Name: $Name</li>
<li>Construction: $Material</li>
<li>Material Handling: $MaterialHandling</li>
<li>Number of Tanks: $Tanks</li>
</ul>
</div>
<div id="Description" class="typography">
<p>Description:</p>
$Description
</div>

<% end_control %>

Thanks!

Avatar
Blackdog

23 September 2010 at 8:07pm Community Member, 156 Posts

Just wanted to say I am experiencing this issue also and wondered if there was a fix.

It only seems to happen when you format within the wysiwyg. If my clients paste in raw text from notepad it formats correctly.

Avatar
Blackdog

23 September 2010 at 8:46pm Community Member, 156 Posts

Try SimpleTinyMCEField rather than SimpleHTMLEditorField

Avatar
theoldlr

24 September 2010 at 6:35am Community Member, 103 Posts

SimpleTinyMCEField was a perfect solution for that problem... Thank you!