Hi!
I am trying to integrate dropbox with my simple module, cool feature by the way, but have some problems with that:
Following steps in CMS Blog
Integrating With Dropbox, notice some typo error:
1. Step 3
-> 'represents' => array(
name='dropbox')
2.Step 4
-> $fields['dropbox'] = array(
type='dropbox' app_key='YOUR_APP_KEY_HERE');
No big deal, but not sure about Step 2 in the end:
...
return $form_builder->create_text($params).' '.$filename;
Well it creates an input field(not button like in tutorial) and there is no opportunity to select or download file from my dropbox account...
I'd like to add this option in my module, please tell me how to do it correctly, it is possible there is some inaccuracy in tutorial.
Comments
$("<input type="\'hidden\'" id="\''.$params['key'].'\'" name="\''.$params['key'].'\'">").insertAfter(".dropbox-dropin-btn");
I've rewrite it this way:
$("<input>").attr({ type: "hidden", id: "'.$params["key"].'", name: "'.$params["key"].'", }).insertAfter(".dropbox-dropin-btn");
and it worked!
I use this feature to make download links for large .psd files stored in my dropbox account, so I do not need to download them on server, however I tried to save .jpg files and set model hook like in tutorial:
function on_before_save($values) { // normalized_save_data is a model property which will include all the $_POST data $dbfile = (isset($dbfile)) ? $normalized_save_data['dropbox'] : ''; if (!empty($dbfile)) { // clean up file name path $filename = rawurlencode(basename($dbfile)); $dbfile = dirname($dbfile).'/'.$filename; $filename = rawurlencode(basename($dbfile)); $dest_file = assets_server_path('images/'.$filename); file_put_contents($dest_file, fopen($dbfile, 'r')); $values['dropbox'] = $filename; } return $values; }
but it just don't work, this hook does not change anything (it saves same values), what is this $dbfile about?
$dbfile = (isset($normalized_save_data['dropbox'])) ? $normalized_save_data['dropbox'] : '';