views:

29

answers:

2

I have a simple component that displays a list of products. I want to separate the products by type. Is there a way through the task= or something like that where I can call a different function in the model? Or... better question: How would I go about using the url to retrieve different data, change a header on the template, but display the data in the same way for each type?

sql will look something like:

SELECT * FROM stoves WHERE type=1
SELECT * FROM stoves WHERE type=2
+1  A: 

Maybe I don't see the complexity but it seems pretty simple. You just need to add another parameter to the url request to your component. Call it "type" for example.

Then your sample url will look like: "index.php?option=com_example&task=view&type=1". Then inspect the value of the "type" parameter in your component's controller and act depending on its value...

silvo
It's not complex at all. I meant to add a line to the question that says "this is stupid easy but I'm hitting a wall!". I figured it out for the most part, though i doubt I'm doing it right. From the controller, how to I call a different view?
hookedonwinter
A: 

You don't need the controller to call a different view. In the controller, look for the additional input "type" in the query string, then create a WHERE clause that you append to your SQL query when pulling the data out of the DB. Be sure that you have a where clause for each type you want to use plus a default for the times type is missing or not defined.

Brent Friar