how to embed image in david persson's media plugin

2011-05-29 Thread crazyDavid
I'm using Media Plugin 1.3 beta with CakPHP 1.3. I've successfully
uploaded the images with the plugin. But how do i use the Media helper
to embed the image file uploaded in the view??? plz help!

Thanks!

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


David Persson's Media Plugin

2011-05-04 Thread Stefan Schlesinger
Hello Folks,

I'm working on my first project with cakephp and I ran into an issue
when trying to
implement file uploads:

1) I'm trying to use the media plugin for my application. I'm having
problems to apply
the polymorphic behavior to the model. Here are my models and the
controller:

models/attachment.php: http://pastie.org/private/qjofpjluwaxsgr4t99jw
models/artist.php: http://pastie.org/private/oqhz5isx4npxdo1b0olvew
controllers/artists_contoller.php:
http://pastie.org/private/x1u10dbgc9awwpxhulqcw

When I upload a new file, its saved correctly into the attachments
table, but without
the foreign_key or the model fields being set.

2) I tried as well to manually add this fields by extending $this-
>data in my controller,
but I end up with a broken string in my database.

Here is the controller with the manually specified model and
foreign_key:

http://pastie.org/private/wrgxo9sdspar3sdxgrpyyq

and the field if its read by the Artist view:

http://666kb.com/i/bt7evphoib2ca2m6y.gif


Regards, Stefan.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: more fields for David Persson's media plugin form?

2011-03-07 Thread David Persson
Hello Tan Cheng,

Just add a new input to your form:

echo $form->input('file', array('type' => 'file', 'label' => false, 
'class' => 'imageUpload')); 
echo $form->input('title'); 

Be sure $this->data looks somewhat like this in your controller action:

array(
  'Gallery' => array(
'file' => '...',
'title' => 'My Title'
  )
);

Than just save the record as you normally do. Make sure there's a 'title' 
column in the table schema. That's basically it.

In case you're using a separate table i.e. 'images' to store the file data 
instead of storing it in the 'galleries' table follow these instructions:

* Gallery and Image models must be associated with each other 
hasMany/hasOne/... 
* Your form must produce a data array which reflects this structure (see 
[1]).
* Use saveAll in your controller action.

[1] 
http://book.cakephp.org/view/1032/Saving-Related-Model-Data-hasOne-hasMany-belongsTo

- David

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


more fields for David Persson's media plugin form?

2011-03-03 Thread Tan Cheng
Hi everyone,

I am now using David Persson's media plugin to handle the ajax upload
now.

But the upload form only shows the file type input, like

create('Gallery', array('type' => 'file'));

echo $form->input('file', array('type' => 'file', 'label' => 
false,
'class' => 'imageUpload'));

echo $form->end();

?>

What if I want to add more fields, like the title of the photo or some
description to add to my image table in db? I have added $form-
>input('title'), but it doesn't show up at all.

Anyone had experience using this plugin? How to customise this?

Thank you very much!!



-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php