Does using conditional blocks in my view defeat the purpose of the MVC architecture?
I have a controller method that loads a view and I want to have a different button group based on the page id that was passed as a paramater to that method.
Everything works fine but in my view I have several:
<?php if($pageID == n) : ?>
html content...
<?php endif; ?>
Is this a bad habit and if so what’s a better solution? Calling a library method from my view seems wrong as well.
There are several ways to avoid that solution, but it really depends on the scale of issue.
A better solution could possibly be something like the follwoing.
View
Controller
If you don’t mind loading views within your views, another simpler way of doing it could be like this:
View
Controller
In the end, you can do this in many different ways, but I hope this could shed some light on some alternative ways to do it.