Active
Project:
Facet API
Version:
7.x-1.5
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2017 at 12:42 UTC
Updated:
30 Mar 2019 at 14:27 UTC
Jump to comment: Most recent, Most recent file
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: