Setting Default Block Views
Permalink 1 user found helpful
I'm curious,
I'd like to make a block that contains several templates for my custom block.
The question is, how can I render from the templates folder by default instead of having duplicate files for certain things.
For example, how can I have two templates for my block, but the second template pulls its view.php from the first template since the only thing that changes is the css.
I'd like to make a block that contains several templates for my custom block.
The question is, how can I render from the templates folder by default instead of having duplicate files for certain things.
For example, how can I have two templates for my block, but the second template pulls its view.php from the first template since the only thing that changes is the css.

You can set the default view to be one of the templates in your templates folder by setting it in the block controllers view method: ... it appears you need to register the css manually though this way. You still need a view.php file in the block root and in the template folders but it can be blank with nothing more than the c5_execute statement.
The only problem with this is you can't switch templates anymore.
<?php namespace Application\Block\Autonav; use Concrete\Block\Autonav\Controller as AutonavBlockController; class Controller extends AutonavBlockController { public function view() { //set default view template $this->render('templates/bootstrap/view'); } }
Indeed, unless you do something like what I did here:
https://www.concrete5.org/community/forums/customizing_c5/determinin...
https://www.concrete5.org/community/forums/customizing_c5/determinin...