Custom Block Template Controller
Permalink 1 user found helpful
Where can I put a custom controller so that it only affects one template and not all?
I'm customizing a Autonav template that needs a different controller, but I want the other templates to continue using the default controller.
If I put the modified controller in Blocks > Autonav > Templates > TemplateNameFolder
it gets ignored. It only works if I put it in Blocks > Autonav but then it will affect all templates which is not good...
What's the solution for this?
Should be simple but I'm not seeing it..
Thanks
I'm customizing a Autonav template that needs a different controller, but I want the other templates to continue using the default controller.
If I put the modified controller in Blocks > Autonav > Templates > TemplateNameFolder
it gets ignored. It only works if I put it in Blocks > Autonav but then it will affect all templates which is not good...
What's the solution for this?
Should be simple but I'm not seeing it..
Thanks
What are you trying to achieve with the new controller?
What I'm trying to achieve is not really the point.. I can make the controller work with a all my templates just fine (I'm just invoking more custom classes, nothing too drastic).
It's about the principle.. If I were to make more drastic changes to the controller that would really affect the other templates, how would I go about it? Is it possible to have different controllers for different templates? Or does the controller have to be unique?
It's about the principle.. If I were to make more drastic changes to the controller that would really affect the other templates, how would I go about it? Is it possible to have different controllers for different templates? Or does the controller have to be unique?
You do mean controller.php, not view.php?
yes
Was just looking for the same answer - did you figure this out?
-cy
-cy
Its a shame, but the only way to have a custom controller is to override the controller globally for the block type.
If you want a custom controller and a custom template, it usually makes more sense to create a completely new block type by copying from the existing block type.
If you want a custom controller and a custom template, it usually makes more sense to create a completely new block type by copying from the existing block type.
That's disappointing - I thought I was just not putting the new controller in the right place.
Thanks for the help!
Thanks for the help!
Is this still the case in v8?
Technically yes.
However, depending on your reason for modifying the block controller there could be other ways round it. For example, if a template requires a few extra edit settings, I found a way round it for my Button Nav addon http://www.concrete5.org/marketplace/addons/button-nav/... .
A new link in the edit dropdown pops up an additional edit dialog for designing buttons associated with a new block template for the autonav block (and other blocks).
Others have used dashboard pages or page attributes to connect to named blocks. Arguably not quite as convenient, but still ways of adding template specific functionality to existing block controllers.
However, depending on your reason for modifying the block controller there could be other ways round it. For example, if a template requires a few extra edit settings, I found a way round it for my Button Nav addon http://www.concrete5.org/marketplace/addons/button-nav/... .
A new link in the edit dropdown pops up an additional edit dialog for designing buttons associated with a new block template for the autonav block (and other blocks).
Others have used dashboard pages or page attributes to connect to named blocks. Arguably not quite as convenient, but still ways of adding template specific functionality to existing block controllers.
Sounds good, thanks for the info. :)