I am trying to link to existing file on the drupal installation. I have added IMCE next to the URL field. I could select the file with imce /sites/default/files/myfile.jpg However, link complains that it is not a valid url so I have to trim / and make it like sites/default/files/myfile.jpg then it works. My PHP skills re very bad I added IMCE by using static name of the field and it fails if I change the name of the field. Could you help me to add IMCE to link and help me to remove / character problem. Thanks

Comments

quicksketch’s picture

Status: Active » Closed (fixed)

This queue is for link.module requests, not for making links anywhere on your Drupal site. Try asking your question in the IMCE queue or in the forums.

mustafadur’s picture

Here is my working but not elegant solution. I have a link field named PDF

go to end of function link_widget and add

 drupal_add_js(drupal_get_path('module','link'). '/test1.js');
  return $element;
}

find

$output .= '<div class="link-field-url' . (isset($element['title']) ? ' link-field-column' : '') . '">' . theme('textfield', $element['url']) . '</div>';

and add

$output .= '<input type="button" value="Browse.." onclick="openFileBrowser()">';

add ltrim to remove / added by imce

function link_cleanup_url($url, $protocol = "http") {
  $url = ltrim($url,"/");

and finally test1.js

function openFileBrowser() {
  window.open('/?q=imce&app=myApp|url@edit-field-pdf-0-url', '', 'width=760,height=560,resizable=1');
}

It is working but it is a mess. I wish you could do cleanup the code. Thanks.