Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

Drupal - Add external JS

0 votes
68 views
added May 23 in Drupal by LC Marshal Lieutenant (14,830 points)
retagged Aug 24 by LC Marshal
<?php
  // vue
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/vue/vue.js",
      array('every_page' => true)
  );
  // lodash
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/lodash/lodash.js",
      array('every_page' => true)
  );
  // vue resize
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/vue-resize/dist/vue-resize.min.js",
      array('every_page' => true)
  );
  drupal_add_css(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/vue-resize/dist/vue-resize.css",
      array('every_page' => true)
  );
  // vue visible
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/vue-visible/dist/v-visible.min.js",
      array('every_page' => true)
  );
  // vee-validate
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/vee-validate/dist/vee-validate.min.js",
      array('every_page' => true)
  );
  // vue-slider-component
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/vue-slider-component/dist/index.js",
      array('every_page' => true)
  );
  // deep diff
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/deep-diff/deep-diff.min.js",
      array('every_page' => true)
  );
  // numeral
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/numeral/numeral.min.js",
      array('every_page' => true)
  );
  // store.js
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/store.js/dist/store.everything.min.js",
      array('every_page' => true)
  );
  // vue-clipboard
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/vue-clipboard/vue-clipboard.min.js",
      array('every_page' => true)
  );

  drupal_add_js(
    "https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js",
      array(
        'every_page' => true,
        'scope' => 'footer',
        'extenal' => true
      )
  );
  drupal_add_js(
    "https://maps.googleapis.com/maps/api/js?key=AIzaSyCeyYod74Cgj-8tc7hbA-kdoT9Uk8bMg84&libraries=places",
      array(
        'every_page' => true,
        'scope' => 'footer',
        'extenal' => true
      )
  );
  drupal_add_js(
    drupal_get_path('module', 'property_cs') . "/js/nanobar.min.js",
      array(
        'every_page' => true,
        'scope' => 'footer'
      )
  );
  drupal_add_js(
    drupal_get_path('module', 'property_cs') . "/js/jquery.timeago.js",
      array(
        'every_page' => true,
        'scope' => 'footer'
      )
  );

  // flickity
  drupal_add_js(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/flickity/flickity.pkgd.min.js",
      array('every_page' => true)
  );
  drupal_add_css(
    drupal_get_path('theme', 'markone') . "/assets/js/vendor/flickity/flickity.min.css",
      array('every_page' => true)
  );

  drupal_add_js(
    "https://cdn.jsdelivr.net/npm/es6-promise/dist/es6-promise.auto.js",
      array(
        'every_page' => true,
        'scope' => 'footer',
        'extenal' => true
      )
  );

  // echo '<pre>';
  // print_r($data);
  // exit;
  $queryString = explode('?', $_SERVER['REQUEST_URI']);
  $queryString = isset($queryString[1])?$queryString[1]:'';
?>

1 Response

0 votes
responded Aug 24 by LC Marshal Lieutenant (14,830 points)

Add external code into template

<?php include(drupal_get_path('theme', 'sello') . '/templates/include/footer.inc.php'); ?>
<?php drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.min.js', 'external');?>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...