I have a custom block with some values I can access in the template of that block, for example the product_type
variable. In the same template file I'm adding another view block with {{ drupal_block('views_block:my-view-block_1', {product_type: 'clothes'}) }}
.
For that block I implemented this hook.
function myModule_views_pre_view(&$view, &$display_id, &$args) {
// I want to access that product_type variable in this hook
// because I want to add a filter.
$view->display_handler->display['display_options']['filters']['field_product_type_target_id']['default_value'] = $product_type;
}
The hook is invoked, but I cannot get the value of product_type
. I'm not sure that is the correct way to achieve it, but I really need to pass that value from first block to second block to filter out results. It's been 2 days I'm trying to figure this out. Any help would be highly appreciated.