CERN Accelerating science

Superfish menu & Jquery in D8 site

Hi,

I’m building https://proto-sidis.web.cern.ch/ , a D8 site, using https://www.drupal.org/project/showcase_lite theme.

One of their ‘features’ is the Superfish menu (which has been ported to D8).

However I am now finding I can’t get the Superfish menu to work, because the site can’t find the superfish library. The library is very definitely present, called “superfish” in lower-case.

I have subsequently found out that jQuery is now in Drupal core, but it’s depreciated and will be phased out for D9. I don’t know if it’s related to my problem, but it’s worth mentioning.

My problem is therefore how do I make this D8 module, on my D8 site, locate the library I have installed (as per instructions) which will make this work?

I’ve been following this: https://www.drupal.org/docs/8/modules/superfish-drop-down-menus/install-superfish

Thanks,
-cath


49

Solution found. You’re going to love this…

The problem is that the module is looking for the libraries in a different place that the CERN architecture currently (at the time of writing, Dec 2019) allows. So we need to update the module file to look in a different place.

  1. Install all things as per instructions at https://www.drupal.org/docs/8/modules/superfish-drop-down-menus/install-superfish

  2. Open the file /modules/superfish/superfish.module

  3. Find the code starting line 212 // Otherwise use the default directory.

  4. Add at the bottom of the elseif cycles, add the following code:

    elseif (file_exists(‘sites/’ . $_SERVER[‘HTTP_HOST’] . ‘/libraries/’ . $library)) {
    directory = 'sites/' . _SERVER[‘HTTP_HOST’] . ‘/libraries/’ . $library;
    }

  5. Save, clear caches, and boom.

Enjoy your newly-working superfishy menus :smiley:

3 Likes

Yes, the problem with Drupal 8 sites is that the Libraries API is not yet stable enough,

So for the moment, either hack the module’s code to look for the library locally or ask infrastructure managers to add the library globally for all the sites.

I would like to see the libraries API ready for Drupal 8 soon, since on multisite environments is crucial.

Cheers,
Eduardo