Use IMCE on custom page | Drupal 8

Use IMCE on custom page

Submitted by editor on Mon, 09/18/2017 - 16:52

How to insert IMCE file browser to a custom form or a custom page.

Example 1 (for drupal 7)

Step 1. Add file brows

Create a simple js file in your module directory (called yourModuleName.js) and enter the following Javascript.

function openFileBrowser() {'/imce?app=yourApp|url@your-input-id', '', 'width=760,height=560,resizable=1');

2) Make sure to include your js file:

$path = drupal_get_path('module', 'yourModuleName');
drupal_add_js($path . '/yourModuleName.js');

3) Create the form element where you want the path to the file to be generated:

$form['your-input-name'] = array(   
  '#title' => t('Your Title'),  
  '#type' => 'textfield',   
  '#attributes' => array('readonly' => 'readonly'), // So that the user cannot manually enter a value  
> );


4) Create a button that will execute the Javascript function:

$form['your-button-name'] = array(
  '#type' => 'submit',
  '#value' => t('Browse Server'),
  '#attributes' => array('onclick' => 'openFileBrowser();'),

Example 2 using inline JS (for drupal 7)

$inlinejs = <<<JS
function openFileBrowser() {'/imce?app=yourApp|url@file-input-id', '', 'width=760,height=560,resizable=1');
drupal_add_js($inlinejs, ['type' => 'inline', 'scope' => 'footer', 'weight' => 5]);

$output = [];
$output['open-imce-btn'] = [
  '#type' => 'submit',
  '#value' => t('Open IMCE'),
  '#attributes' => ['onclick' => 'openFileBrowser();'],


R HILDAN M (not verified)

Fri, 12/14/2018 - 17:06

link 9 agen astm a283 c agen pipa boiler agen plat abrex 400 agen plat asme516 grade70 agen plat astm a285 c agen plat astm516 70 agen plat boiler agen plat hardox agen plat hb 400 agen plat high strenght agen plat high tensile sm490 yb agen plat high tensile sm490ya agen plat kapal agen plat stainless ss304 agen plat stainless ss310 agen plat stainless ss316 agen plat sumihard agen round bar besi aisi 440s45c agen round bar scm440 agen steel rail agen steel sheet pile distributor astm a283 c distributor pipa boiler distributor plat abrex 400 distributor plat asme516 grade70 distributor plat astm a285 c distributor plat astm516 70 distributor plat boiler distributor plat hb 400 distributor plat high strenght distributor plat high tensile sm490 yb distributor plat high tensile sm490ya distributor plat kapal distributor plat stainless ss304 distributor plat stainless ss310 distributor plat stainless ss316 distributor plat sumihard distributor round bar besi aisi 440s45c distributor round bar scm440 distributor steel rail distributor steel sheet pile jual astm a283 c jual baja h beam jual pipa boiler jual plat abrex 400 jual plat asme516 grade70 jual plat astm a285 c jual plat astm516 70 jual plat boiler jual plat hardox jual plat hb 400 jual plat high strenght jual plat high tensile sm490 yb jual plat high tensile sm490ya jual plat kapal jual plat stainless ss304 jual plat stainless ss310 jual plat stainless ss316 jual plat sumihard jual round bar besi aisi 440s45c jual round bar scm440 jual steel rail jual steel sheet pile pabrik astm a283 c pabrik pipa boiler pabrik plat abrex 400 pabrik plat asme516 grade70 pabrik plat astm516 70 pabrik plat boiler pabrik plat hb 400 pabrik plat high tensile sm490 yb pabrik plat high tensile sm490ya pabrik plat kapal pabrik plat stainless ss304 pabrik plat stainless ss310 pabrik round bar besi aisi 440s45c pabrik round bar scm440 pabrik steel rail pabrik steel sheet pile pusat astm a283 c pusat pipa boiler pusat plat abrex 400 pusat plat asme516 grade70 pusat plat astm a285 c pusat plat astm516 70 pusat plat boiler pusat plat hardox pusat plat hb 400 pusat plat high strenght pusat plat high tensile sm490 yb pusat plat high tensile sm490ya pusat plat kapal pusat plat stainless ss304 pusat plat stainless ss310 pusat plat stainless ss316 pusat plat sumihard pusat round bar besi aisi 440s45c pusat round bar scm440 pusat steel rail pusat steel sheet pile stockis plat hardox stockist plat astm a285 c stockist plat high strenght stockist plat stainless ss316 stockist plat sumihard supplier plat hardox

Add new comment