Reputation: 1503
A have a CI 2 project, and in a view I have 3 box, and I have to show them on different page, different routes. Approximately on 8 different route, so where suppose I declare them?
In the view in every function( 8 of them) or in the one view file and check for the current route if it's match the criteria. The problem, that not all of them should be shown, A box only in 5 view, B box in 4 and C box in 2 example.
Upvotes: 2
Views: 72
Reputation: 55962
I would declare it where it is most centralized. Checking to load the view in every function would mean that if you were to change your condition you'd have to update it in 8 different places!! That is not fun to maintain.
By checking in one view file everythin is more centralized. This might seem silly because your conditional can get big,
if ($is_route_1 || $is_route_2 || $is_route_4 || $is_route_5) {
// display the box
}
So if you wanted to display it on another page you can add it right here in the one view.
Upvotes: 2