I would like to programmatically and conditionally show a facet block, if the returned values match some certain criteria. I have not found any solutions so far. For example, if a facet returns 25 apples, I would like to show an additional facet that does some calculation on this value.


If you used Search API, this code should help you:

$delta = facetapi_hash_delta(facetapi_build_delta('search_api@INDEX_MACHINE_NAME', 'block', FACET_NAME));
print render(module_invoke('facetapi', 'block_view', $delta));
  • @kenorb, it's wrong correction because as I told, my example is for search api – Eugene Nov 27 '15 at 13:42
  • It returns an empty value with form_alter but working on tpl file. Don't know why this is happening. – Rajesh Vishwakarma Sep 18 '20 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.