Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » SimpleHTMLEditorField doesnt use paragraph tags?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1734 Views
  • theoldlr
    Avatar
    Community Member
    103 Posts

    SimpleHTMLEditorField doesnt use paragraph tags? Link to this post

    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!

  • Blackdog
    Avatar
    Community Member
    156 Posts

    Re: SimpleHTMLEditorField doesnt use paragraph tags? Link to this post

    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.

  • Blackdog
    Avatar
    Community Member
    156 Posts

    Re: SimpleHTMLEditorField doesnt use paragraph tags? Link to this post

    Try SimpleTinyMCEField rather than SimpleHTMLEditorField

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: SimpleHTMLEditorField doesnt use paragraph tags? Link to this post

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

    1734 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.