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.

ob7dev
 
ob7dev replied on at Permalink Best Answer Reply
ob7dev
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:
$this->render('templates/default/view');
... 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.
c5dragon replied on at Permalink Reply
c5dragon
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');
    }
}
ob7dev replied on at Permalink Reply
ob7dev
Indeed, unless you do something like what I did here:
https://www.concrete5.org/community/forums/customizing_c5/determinin...