Beginner needs advice for (yet another) layout problem |
[eluser]oll[/eluser]
Hello all, I'am developping a Youtube-like application for my work. The first version was done from scratch whith PHP Mysql but I try to make it work the same with CI. I'm not a developper (only a poor admin ) , so excuse me in advance for the ugly code ![]() The application is quite simple. To simplify it, it has 3 components : * a form for choosing the month/year/group (this is actually a more sophisticated search engine) * a playlist that displays all links to choosen videos from the selected month/year/group * a player that runs the video in a flash player, displays the description, shows comments and allow users to post new ones. So I created a Videos controller in which I have these 3 functions. Here is a piece of code for illustrating it : My controller : Code: <?php My views : * form_gam : Code: <?php * playlist_view Code: <div id="right"> * player view (video_view) Code: <div id="left"> So all that works : If I do a : http://mysite.com/index.php/videos I have the form. If I choose a month/year/group, I have my playlist in another page. If I click on one video from the playlist page, It opens me a new page whith the player. (I tried to respect the MVC model) But what I would like, is to have all that in the same page : the form in the top, the player to the left and the playlist to the right. The problem is that I don't want my playlist to be reinitialized when I click on a video. (actually, the generated playlist depends on more choices (not only group/month/year but also tags, author, "search in description", etc...) What I did to try to display everything in the same page is : * change my playlist_view to a form pointing to my controller , instead of a elegant link to my createplayer function. * Put a : Code: if (isset($_POST['video_id'])) { and Code: $this->player($video_id); in my index function. But the problem is that my playlist is "reinitialized" since this creates a new instance of my controller. It also can be technically solved, passing all the $choice element as hidden inputs in the former form, and adding all "if isset($POST .." in the index() function or constructor of my controller. But this is very ugly, no ? Do you know if there an elegant way to do it ? (whenever possible without adding frames) I spent hours goggling or reading the CI Wiki with no success. I think I read everything about Layout and embedded views , but I didn't find something speaking about how to change partial views contents without creating a new instance of a controller. (in abstract, my player view needs to be changed , while my playlist view remains the same). Thank you very much.
[eluser]Dready[/eluser]
Hello and welcome to CI, I see two ways of doing this : * using "Ajax frame" (ajax to update a part of your DOM), just like deezer and others * using a session object to store the current playlist for a user
[eluser]oll[/eluser]
Thanx to the very great codeigniter user guide, I succeed in having what I wanted using sessions ! Thank you very much ! |
Welcome Guest, Not a member yet? Register Sign In |