I'm trying to figure out how to make a certain button and can't for the life of me figure out how to do it.

Essentially what I want to do is have the ability for users to select a file and have the link to the file placed in a list with some predefined text around it. I'm using IMCE to allow users to select uploaded files but can't figure out where to put the code to place all my additional code. I have attached a screen show of what I would like the final version to look like.

Any help is appreciated, and apologies in advance if this is the wrong place to request assistance. Thank!

Bob

CommentFileSizeAuthor
List File Example.jpg125.51 KBBob Moyce

Comments

ufku’s picture

This example uses IMCE to get a file information. Also demanding an extra input from the user, it creates the html string where it uses all these variables.

js:
//make IMCE send the selected file to our file handler myImceHandler()
window.open('/imce?app=BUEditor|sendto@myImceHandler', '', 'width=760,height=560,resizable=1');

myImceHandler = function(file, win) {
  //close imce window
  win.close()
  //we have properties of file(url, name, size, date, width, height)
  //get extra input if needed.
  var extra_input = prompt('Enter extra input', 'Extra input');
  //create the string we will insert
  var str = '<div>File url: '+ file.url +'<div>\n';
  str += '<div>File size: '+ file.size +'<div>\n';
  str += '<div>Extra input: '+ extra_input +'<div>\n';
  //insert the string into the textarea
  BUE.active.replaceSelection(str);
};

Note the php tags are for only coloring purposes.

Bob Moyce’s picture

Thanks for the input but I'm having trouble with the IMCE part. When a user clicks the button, I get an "Object not found!" error even though I have IMCE installed. I have had success using this piece of code to pull up IMCE for other buttons:

php:
$imce_url = function_exists('imce_access') && imce_access() ? url('imce') : '';

What is the easiest way to merge the two so that the same style pop-up window can be used?

Thanks.

Bob

ufku’s picture

change the line that opens imce window to:
window.open(Drupal.settings.basePath +'index.php?q=imce&app=BUEditor|sendto@myImceHandler', '', 'width=760,height=560,resizable=1');

Bob Moyce’s picture

Great thanks! This helps a lot.

Bob

ufku’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.