Confusion: p-tags in blocks become div style=margin:0

Permalink
Something very odd happens here in my code :-D

I have a custom block type where I can add content via the TinyMCE editor. When I look at blocks I've created with this block type directly they all display fine.

But when I grab one of the blocks somewhere else on the page in a view like so

$block = Block::getByID($someBlockID);
$bv = new BlockView(); 
$bv->render($block);


the p-tags become <div style="margin:0"> ?!!?

See pic attached...!

1 Attachment

nerdess
 
cgrauer replied on at Permalink Reply
cgrauer
First of all, this makes no sense:
$bv->render($block);

It should read something like this:
$bv->render('view');


But perhaps the blocks you created use a custom template. If so, replace 'view' with 'templates/xxx' where xxx is the filename of the custom template (without ".php").
nerdess replied on at Permalink Reply
nerdess
Ermmmmm.....my code actually does make sense and the content is there and wrapped in lovely html EXCEPT the content that got added with TinyMCE

The render method from BlockView() expects as first parameter a block object and as second parameter the optional template name with "view" as default.

Seehttp://www.concrete5.org/community/forums/customizing_c5/how_to_cal...

:-)
nerdess replied on at Permalink Reply
nerdess
Oh dear I just found out what was wrong.........actually it's nothing I just looked at two different blocks that were quite similar but had those little differences in the HTML.

Very sorry, false alarm all good with Concrete5 :-D
cgrauer replied on at Permalink Reply
cgrauer
You're right, sorry! I mixed up BlockView::render() with BlockType::render()!