Jump to content

how to arrange content in bootstrap grid in ckeditor ?


Recommended Posts

Posted

Is there a pressing reason to mix this level of layout into your content? Would separating the columns into individual textareas and moving the layout details into your templates work better?

  • Like 2
Posted

you could also try using a token like {{column-break}} and then use this function on your body field output:

function columnizeMarkup($markup) {
	if(strpos($markup, '<p>{{column-break}}</p>') == false) return $markup;
    $bodyParts = explode('<p>{{column-break}}</p>', $markup);
    $colClass = 12 / count($bodyParts);
    $columns = '';
    foreach($bodyParts as $col) {
        $columns .= "<div class='col-md-{$colClass}'>$col</div>";
    }
    return '<div class="row">' . $columns . '</div>';
}

 

  • Like 8
Posted

@adrianmak I would strongly consider you don't put divs in CKeditor fields as this is a very fragile and error-prone approach.  My solution to this is either (a) use HannaCodes to represent opening and closing of divs or (b) use RepeaterMatrix.

  • Like 3
Posted

and in my example, it only works if you want to columnize the whole field, else you also need to extend that function to have a row/section break

Posted
On 11/2/2016 at 6:12 PM, netcarver said:

Is there a pressing reason to mix this level of layout into your content? Would separating the columns into individual textareas and moving the layout details into your templates work better?

the site is supporting responsive layout.  Users will add in-line images in anywhere of the content body. In this case without using grid to layout content in the body field, the final look view in mobile devices may look not properly

 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...