Hello.
I have recently started using the CodeIgniter framework for my PHP development.
I was just curious as to correct usage.
Essentially I have the following situation.
I have a controller entitled 'items'
I want it so if the user goes to items/index they get a list of caetgories, if they go to items/category-name they get a list of items.
To achieve this, I have the one controller with an if/elseif statement which loads different views. Is this the correct approach?
If i am on a items/category-name page, I load a view entitled 'items-list' I pass a variable entitled $type to this view.
In the view it detects this type (again with an if statement) and outputs the category title (also passed). Simple.
As well as this I have a completely different controller for a recently sold items list (dont ask :)). As the format of the list to display is essentially the same I utilize the same view, but pass a different $type var. The view detects this, outputs various 'extra' links, images etc and of course does not output a 'categories' title.
Essentially I have 2 controllers utilizing one view. With various if/elseif statements in both the controllers and the view to get the right output.
Is this the correct approach?
Thanks