I am fairly new to symfony and I am currently doing a school project with it.
I have to make a functionality where my users can upload youtube link video (like a blog post but with a video). So I decided to use sonataMediaBundle to handle the upload of my links.
I have SonataAdminBundle and SonataUserBundle already installed. It allows me to have my CMS already set up but I found that only the admins can upload links and I can't found how to allow my users to upload link video without give them access to all my CMS in SonataMediaBundle.
Ok I'm progressing on my project, I making it simply (without Sonata).I've got one problem with doctrine, I can't retrieve my database objects.
I followed the symfony doc so I have my "showAction".
public function showAction($id)
{
$video = $this->getDoctrine()
->getRepository('MediaBundle:Media')
->find($id);
if (!$video) {
throw $this->createNotFoundException(
'No video found for id '.$id
);
}
return $this->render("MediaBundle:LinkUpload:linkupload.html.twig", array(
'video' => $video,
));
}
Then in my template I'm doing:
{% for item in video %}
{{ item.name }}
{% endfor %}
I also tried without the id parameter and use findAll() instead of find() but I always get an error telling that my variable "video" does not exist.
Any idea about that ?
And I also would like know: how do you properly upload a youtube link video ? I was thinking about put a tag and ask the user to upload embed youtube link every time but is it not to complicated to do that ? (for the users I mean).
Thanks in advance for your upcoming answers !