Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Integrating With Dropbox

edited May 2015 in Feature Requests
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.


  • edited 1:50AM
    Thanks for pointing out those typos in the post (their is a parsing issue when we don't escape angle brackets). Your issue sounds like it's not triggering the javascript for Dropbox. If you view source do you see the call to ""?
  • edited 1:50AM
    Yes, it does make call to dropins.js, there was another typo in this line:
    $("<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?
  • edited May 2015
    That $dbfile line has a typo and should be:
    $dbfile = (isset($normalized_save_data['dropbox'])) ? $normalized_save_data['dropbox'] : '';
Sign In or Register to comment.