Hello, let’s say I have a URL /index.php/Channel/20. This url corresponds to the actionView in the ChannelController using id=20. Now, what I want is for each channel to show a list of Shows (another model) that are on that channel. So for example, if I went to /index.php/Channel/20/Shows, it would show me all the shows on channel 20. How in the controller would I know that the user has gone to the /Shows url? How would I write an action that corresponds to that parameter? Thanks.
You have to mess around with the url manager.
You show controller takes a channel as a parameter, right?
So you need to shuffle the url a bit.
You have to pass $id and $channel in your url.
And put those two as parameters to your show/view action.
I am constantly confused by the url rules myself.
It’s true that I have a Shows Controller, but I really need the shows to fall under the umbrella of channels. For example, I want users to click on Channel 5 link and go to /index.php/Channel/5. Then they can click on Shows and go to /index.php/Channel/5/Shows. Then click on show XYZ and go to /index.php/Channel/5/Shows/XYZ. The URLs don’t have to be exactly like that, but I need it to be some kind of hierarchy. I don’t want users to just be able to go to /index.php/Shows/XYZ. The shows HAVE TO belong to a certain channel. This is my biggest struggle with Yii, I just can’t make sense of this situation.
The way I have it now so far is that if you go to /Channel/5 you see Shows, which I display with a Widget I created that gets all the shows that correspond to that channel. However, I haven’t been able to go deeper than that yet.