开发者

Request different data from the same component in Joomla

I have a simple component that displays a list of products. I want t开发者_如何学Pythono 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


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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜