This is my first question on here–though I’ve used it for years for reference–so, please forgive me if this is trivial/already answered, but I wasn’t able to find a solution.
I have a render array being returned to the ‘content’ attribute of a block view array. I’m just returning a table as of right now.
<?php
$data = array(
'#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
);
return $data;
?>
What I’d like to do is add additional markup at the beginning. I’ve tried adding a ‘#prefix’ attribute, but the results weren’t as expected; I ended up with HTML outside of the block. Anything else I thought would work seems to cause PHP errors or do nothing at all.
When using HTML tags with #prefix they should be closed with #suffix.
Did you remember to close the content in #prefix?
Like so:
Edit
To control the output as HTML rather than a render array one could use the hook_block_view() hook to feed the $block[‘content’] with pure HTML rather than a render array.
According to the documentation the $block[‘content’] can handle both types of input.
If you don’t want to use the block view hook I guess you could render your render arrays in this manner instead:
See render() for a reference.
Also remember to clear your caches like stated in this answer.