views do work in homebox, the code is just not being handled properly.
In the function homebox_prepare_block() there is:
<?php
if (isset($block->content) && !is_array($block->content) && trim($block->content)) {
?>
What needs to be done here is:
if block->content is not set, then that should return NULL.
if block->content exists, then if block->content is not an array and is an empty string then return NULL.
All other cases should continue.
(If block->content is anything other than an array or a string, then should this also return NULL as well?)
The resulting changes to the above code looks like:
<?php
if (!isset($block->content) || !is_array($block->content) && trim($block->content) == "") {
?>
Now for the case when block->content is a string, the theme needs to handle it accordingly.
In homebox-block.tpl.php, the following change is what I made:
- <div class="portlet-content content"><?php print drupal_render($block->content); ?></div>
+ <div class="portlet-content content"><?php if (is_string($block->content)){ print $block->content; } else { print drupal_render($block->content); } ?></div>
Not very elegant, but it works.
If it is possible, I think it would be better to convert the string into an array so that the theme template should only need to handle the array case. The problem here is that I do not know how the array should be structured to do this properly.
Attached is a patch that makes the mentioned changes.
With this patch, views work with homebox.
Comment | File | Size | Author |
---|---|---|---|
homebox-string_block_support-1.patch | 1.4 KB | thekevinday | |
Comments
Comment #1
brianV CreditAttribution: brianV commentedVery nice fix - thank you for sending this one in. I've tested it, and it works perfectly.
I do think that we could fix it up a bit in order to remove the logic from the template file... but at this point, I don't think the effort is worth it if it works as-is currently. We can always put the time into looking at that later if necessary.
Anyways, committed:
http://drupal.org/cvs?commit=500050