1

I am working on porting module to drupal 8.

My block code is as follow public function build() { $delta= $this->getDerivativeId(); $num = str_replace('dexp_layerslider_block_', '', $delta); $sid = $this->configuration['dexp_layerslider_block_slide_'.$num]; $block_id = $this->getDerivativeId(); $slideshow = dexp_layerslider_load($sid); if (!$slideshow){ return 'No slider selected'; } $content = array( 'id' => $sid, 'slides' => $slideshow->slides, 'settings' => $slideshow->settings ); return array( '#theme' => 'dexp_layerslider_slides', '#items' => $content, '#attached' => array( 'library' => array('dexp_layerslider/dexp.block'), ), ); } my yaml file: dexp.slides: version: 1.x css: theme: plugins/font-awesome/css/font-awesome.min.css: {} css/admin.style.css: {} plugins/rs-plugin/css/settings.css: {} js: js/dexp.layerslider.js: {} js/layeroption.js: {} js/admin.layerslider.js: {} plugins/rs-plugin/js/jquery.themepunch.revolution.min.js: {} plugins/rs-plugin/js/jquery.themepunch.tools.min.js: {} dexp.block: version: 1.x css: theme: plugins/rs-plugin/css/settings.css: {} css/layerslider.css: {} js: plugins/rs-plugin/js/jquery.themepunch.revolution.min.js: {} plugins/rs-plugin/js/jquery.themepunch.tools.min.js: {} dependencies: - core/drupal - core/jquery my theme function : $themes['dexp_layerslider_slides'] = array( 'template' => 'slides', 'path' => $path . '/theme', 'pattern' => 'layerslider__', 'preprocess functions' => array( 'template_preprocess', 'dexp_layerslider_preprocess_slides' ), 'variables' => array('items'=>null), ); None of javascript and css files are load , when i try to access items in twig template {{ items }} nothing gets printed , though if write random string in the my slide.html.twig file it get printed. where i could be going wrong?

1

You don't have a "dexp.slide" defined in your libraries.yml file. Only "dexp.block".

You're trying to attach a library that doesn't exist.

7
  • I was trying to post less code, i will update my question
    – Aditya
    Mar 23 '17 at 14:03
  • its working now , i am using vi editor and i type the the above instead of copy and pasting and it started working!
    – Aditya
    Mar 23 '17 at 14:57
  • I don't know what that means - other than the code in the post is still wrong. You are referencing a library to attach which doesn't match what is in your libraries.yml file, which is absolutely why none of those files are loading.
    – Kevin
    Mar 23 '17 at 14:59
  • i do have dexp.block and file associated with dexp.block. some how it was not working and i retyped in vi editor it started working .
    – Aditya
    Mar 23 '17 at 21:10
  • i updated my question.
    – Aditya
    Mar 23 '17 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.