Determining the custom template applied to a block from the blocks controller
Permalink 1 user found helpful
How do I check and determine what custom template is applied to a block?
I would like to know because I am making a block with a couple templates, but the view.php always stays the same. So to keep things simple I am running the render function from the controller view method. That way the same view is always rendered, but my CSS for each template needs to target the bID instead of just loading a CSS file. Since the same view is always rendered I need a way to check what template is set on the block and insert my CSS from there.
I would like to know because I am making a block with a couple templates, but the view.php always stays the same. So to keep things simple I am running the render function from the controller view method. That way the same view is always rendered, but my CSS for each template needs to target the bID instead of just loading a CSS file. Since the same view is always rendered I need a way to check what template is set on the block and insert my CSS from there.
use Concrete\Core\Block\View\BlockViewTemplate;
From your view method get the template:
Returns the full path to the template.
So to determine if a certain block template is active you can search for it: