Hi,
I created facet api block and I want to theme it (not only css, I want to add some divs, classes, etc)
I'm trying to invoke the block in other template, but without success.
There aren't default template for this block, that I would be able to override.
There aren't any hook function for this.
Any suggestions?
Thank you in advance :) .
Edit:
Also a way to render facet api block programmatically, by invoking the hook_block_view() in the module would be awesome!
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | Selection_013.png | 18.63 KB | letrollpoilu |
Comments
Comment #2
abh.ai commentedI'm facing this same issue. I'm trying to render a facet api block programmaticaly. For some reason it isn't working like other regular blocks.
`$block = block_load('facetapi', 'H8t5HB0FXQR0lyo2OdJ6i9pqGROuNg6r');` works like every other block, but
`$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));` returns an array with one element i.e., `#sorted => TRUE`
facetapi_block_view('delta') also returns 'null'
Comment #3
abh.ai commentedComment #4
PiersShepherd commentedIm experiencing the exact same output as @abhaisasidharan.
This would be useful as I prefer to control block visibility in my templates and not in the block management system/context/etc.
Comment #5
PiersShepherd commentedAfter more testing and setup I managed to get a facetapi block to render using:
$block = block_load('facetapi', 'H8t5HB0FXQR0lyo2OdJ6i9pqGROuNg6r');
$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
The reason I was seeing only seeing #sorted => TRUE before was that my facet block was set to hide under certain situations:
- Hide items that do not change search result.
- Hide if no search is performed.
Once these options were unticked in the visibility settings for the facetapi block then it showed :)
So if anyone finds this page and is trying to render a facetapi block programmatically and it's not showing, you may need to disable some of the 'do not show' options in the block visibility config.
Comment #6
letrollpoilu commentedDear PiersShepherd,
Thanks a lot for that post, it has proven very helpful. Somehow there are no good examples of including facets with PHP anywhere else.
I'm still having the issue where the facet only render "Sort".
So I looked in the block configuration, but it all looks good to me, I don't see the options you are mentioning.
Comment #7
letrollpoilu commentedOk I found out, for me the issue is that I was calling the factet block before generating the index. Here is my code: