Hi Saul
This isn't possible without writing some custom code and using the relationships API, which I get the impression you are capable of.
You want to output (custom) categories, so you would create a View with this taxonomy as the content selection, and without any filters it will simply output all of the categories.
We need to tell it that it should only get the categories of a limited set of posts, specifically the section posts that are related to the current catalog post we are displaying.
So
1. use the wpv_filter_taxonomy_query API hook to intervene in the query that retrieves the categories (see https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_query)
2. use the toolset_get_related_posts API hook to get the sections posts which are related to the current catalog post (see https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts)
3. pass this list of posts as an array of IDs to the object_ids taxonomy View query arguments, to limit the queried list of categories to those which are assigned to these posts (see https://developer.wordpress.org/reference/classes/WP_Term_Query/__construct/#parameters)
I'll let you put the pieces together, but here is a simple example of using the wpv_filter_taxonomy_query and *manually* specifying which posts to limit the search to:
toolset_snippet_security_check() or die('Direct access is not allowed');
function tssupp_custom_tax_query($tax_query_settings, $view_settings, $view_id) {
if (in_array($view_id, array(308))) { // Edit ID of View to apply to
$tax_query_settings['object_ids'] = array(99, 199, 299); // array of post IDs
}
return $tax_query_settings;
}
add_filter('wpv_filter_taxonomy_query', 'tssupp_custom_tax_query', 101, 3);
And as the documentation is a little opaque, here is an example of using toolset_get_related_posts. Note that although with many-to-many relationships the post types are effectively on a par, the API still adopts the custom of parent and child to describe the left and right sides of the relationship.
$children = toolset_get_related_posts(
$parent_id, // ID of starting post
$relationship_slug,
array(
'query_by_role' => 'parent', // start from the parent
'limit' => 999,
'return' => 'post_id', // return an array of post ID's
'role_to_return' => 'child' // return the child
)
);
Let me know how you get on.