First of all, I’m loving Yii, many thanks to all the creators and contributors ![]()
I’m pretty new to MVC, so I am struggling with parts, but I have a reasonable PHP and OOP background.
Overall, I am getting my head around how it works, but I have a lot to learn…
I am building a blog site starting from the blogdemo base.
I added a Media class to handle images and video I plan to upload.
I’m using the excellent FancyUpload and CThumbCreator, both of which are working well.
I added a button to post/update called ‘Manage Media’ the links to media/admin taking the post_id with it to only show media for that post. The FancyUpload widget sits at the bottom of media/admin.
CThumbCreator is called at the end of actionUploadedFiles in FancyController.
The saves the files no problem, next I want to add the data to the database.
So just after CThumbCreator does its stuff I created a new Media object, fill its attributes and save it.
This works fine, but there is one attribute I’m struggling to get in FancyController, post_id.
edit - post_id is the foreign key in the Media model linking it to the Post model.
I have tried various ways of saving it in actionUpdate of PostController to later pick it up in FancyController, including sessions and cookies, none of which I could get working.
I’m still learning how to effectively read the class reference so I’m probably making a simple mistake, but I don’t have any errors to go on, nothing in the log file.
So my question is, what is the best way to do this? And do you have some example code? ![]()
Does my setup seem reasonable to you or is it fundamentally flawed in some way?