633 Posts in 170 Topics by 237 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1591 Views |
-
File Upload in Widget does not work (backend)

8 February 2010 at 10:42am
Hello all,
I want to create a widget. The widget has the possibility to upload an image in the backend area. In the frontend the widget just outputs the image. Basically the widget works fine. But somehow the File Upload never works. The widgets appear in the database, but they always get FileId 0. If I set the FileId in the database to a proper/existing value the outputted site looks perfect.
Thats my code:
<?php
class StandardTeaser extends Widget {
static $title = "Neuer Standard-Teaser";
static $cmsTitle = "Neuer Standard-Teaser";
static $description = "Neuen Standard-Teaser anlegen";
static $db = array(
'Header' => 'Text'
);
static $has_one = array(
'File' => 'File'
);
function getCMSFields() {
$fields = new FieldSet();
$fields->push( new TextField('Header'));
$fields->push( new FileField('File'));
return $fields;
}
}
?>if I use ImageField instead of FileField then the backend does not even appear.
Is there something special with file uploads in widgets?thanks so much,
florian -
Re: File Upload in Widget does not work (backend)

20 April 2010 at 8:23am
Exact same question here
Help appreciated -
Re: File Upload in Widget does not work (backend)

13 August 2010 at 7:17am Last edited: 17 August 2010 2:58am
*snip*
-
Re: File Upload in Widget does not work (backend)

14 August 2010 at 12:51am
I don't have a direct solution for you, and I've never made any widgets before(nor have used them)
but why don't you check how they did it in cms\code\AssetAdmin.php (better yet, extend that class, if that's possible with widgets)
They handle all uploading, moving and storing. Create a new function that saves all your banners/images/slides into a database table, and extract that then into the front-end.I'm subscribed and following this, as I was planning to write something on my own. However, I first need to complete my bizz-website before I can go experimenting.
Hope this helps a bit...
-
Re: File Upload in Widget does not work (backend)

17 August 2010 at 3:01am
Well I have finished my code and it is a bit simpler that I'd imagined and works!
I did notice that this was about files in the backend so I've removed the code I have and instead I'll link over to the post with the image solution... to do the same thing with files should be fairly easy (just change what is shown instead of an image thumb).
an image solution...
http://www.silverstripe.org/widgets-2/show/267667?start=0#post290372Barry
| 1591 Views | ||
|
Page:
1
|
Go to Top |



