I'm not sure if this is a bug, but it looks like it.

Go to http://79.170.40.231/thedocsmanchester.co.uk/?q=node/272 . You should get three groups of collapsed embedded links. If things are working as they should, you can expand and collapse the groups as normal.

Now navigate away from the page to another page on the site. Return to the original page (choose 'Sexual Health' in the left sidebar). If you are seeing what I'm seeing, the groups are no longer expandable. This remains true for any other pages with embedded links.

However, if you go to the main links page:
http://79.170.40.231/thedocsmanchester.co.uk/?q=weblinks the groups are still expandable.

Is this an issue with my theme or a conflicting module? Or is the link-embed contrib not loading the JS correctly?

Site caching is currently disabled if that's any help.

Comments

jamesbisset’s picture

Version: 6.x-2.x-dev » 6.x-2.3

Update: I've downgraded to 6.x-2.3, disabled all except core modules (plus Devel) and switched to Garland: still the same result.

The source code for a collapsed fieldset look like this:

<fieldset class=" collapsible collapsed"><legend>My links</legend>

If the JS has done its job this is rewritten as:

<fieldset class=" collapsible collapsed"><legend><a href="#">My links</a></legend>

What's happening is that if I revisit a page with an embedded link, the <a href="#">My links</a> doesn't get written, thus disabling the expandability. Using Devel to clear the cache restores the functionality until I navigate away and then come back to the page.

However, the collapsed fieldsets on the weblinks main links page always remain expandable. I can see the fieldsets load and then the group titles get activated as links - the wee arrows appear last.

Any tips on how I can pin down what's happening here? I notice that links-embed requires Menu. Any way of troubleshooting that relationship?

jonathan1055’s picture

Version: 6.x-2.3 » 7.x-1.x-dev
Category: Support request » Bug report
Issue summary: View changes

I've tested this in Drupal6 and the collapsing/expanding works correctly in general, and as it has been nearly six since this issue was raised I was going to close it as 'cannot reproduce'.

However, on testing in Drupal7 the jquery does not activate and the fieldset legend does not become a clickable links. Which means that the fieldsets are currently collapsed with no way to expand them. It might be due to how D7 treats javascript files but it seems that we need to explicitly add:

drupal_add_js('misc/form.js');
drupal_add_js('misc/collapse.js');

at the top of weblinks_embed.module, then it works OK. I'll make a patch for this.

I have also discovered that the filter settings in weblinks_embed_filter_info and weblinks_embed_settings have not been coverted correctly from the D6 code, so the values cannot be saved or acted on. That is a new issue which I will raise separately.

GStegemann’s picture

However, on testing in Drupal7 the jquery does not activate and the fieldset ...

I tested embedded link groups but it works on my test site. The fieldset legends are clickable any time the page is displayed or revisited. How did you test embedded links?

I have also discovered that the filter settings in ...

I will wait for your issue.

jonathan1055’s picture

I just created a new page and added the syntax for embedding a group. When the legend was not clickable I checked the console log in Firefox to try to see what files and javascript was active. That's when I found out that collapse.js was not loaded. However, it does get loaded on the main Web Links page and we do not explicitly include those files. Maybe because the page includes a form then they are automatically added. My test page had no form (even though we add the fieldset) so maybe that was the difference. I will try to replicate it with a clean minimal D7 install.

jonathan1055’s picture

StatusFileSize
new6.34 KB

I've just replicated the problem, would be good to see if you can too:

  1. Install a clean Drupal7 (I used 7.38) using standard profile (or drop all db from an existing db and re-install)
  2. Use default theme Bartik
  3. Enable Weblinks and Weblinks embed
  4. Navigate to /weblinks and create a Web Links group
  5. Create a Web Link node (either manually or via Devel Generate and set the group to the one created above
  6. Edit the 'full html' filter at admin/config/content/formats/full_html and tick 'Web Links Embed' then 'save configuration'
  7. Create a new 'Basic Page', enter [links-embed:1] for the content, switch the text format to 'full html' and save the node

Now, depending on the 'collapse' setting of the group, the fieldset will either be shown expanded or not, but in both cases the legend is not converted to a clickable link because collapse.js is not added to the page. I have uploaded a text file showing the javascript files added on that page. Compare this with the files added on the main Web Links page which include form.js and collapse.js

GStegemann’s picture

... would be good to see if you can too:

I can replicate the problem as well. I have a second test site which shows exactly the same behaviour as you described in #5.

So in fact Web Links Embed needs to be fixed.

jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new516 bytes

Here's a patch which fixes the problem. I am not sure how these files get added on our main weblinks page without our module code explicitly doing these lines. I tried adding a form around the test embed page from #5 and that does not trigger the files. It would be nice to fully understand this, because it may have implications on the rest of the module. However, that should not stop us fixing the problem in embed here. I've mentioned this issue in the fix, so that in future we can track back to why the lines were added.

GStegemann’s picture

Status: Needs review » Reviewed & tested by the community

Here's a patch which fixes the problem.

Thanks. I have tested it and it works.

I am not sure how these files get added on our main weblinks page

Maybe by Views.

It would be nice to fully understand this,

Yes. But I have no idea yet.

  • jonathan1055 committed 7140360 on 7.x-1.x
    Issue #618192 by jonathan1055, jamesbisset: collapsed link-embed will...
jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: +#2564473: Weblinks-embed filter settings cannot be saved

Thanks for the testing. Setting this to fixed as D6 works OK.
The new issue for the settings is #2564473: Weblinks-embed filter settings cannot be saved

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jonathan1055’s picture

Status: Closed (fixed) » Fixed

From #7:

I am not sure how [the jquery files] files get added on our main weblinks page without our module code explicitly doing these lines ... It would be nice to fully understand this, because it may have implications on the rest of the module.

I found the answer:

function weblinks_page($tid = 0) {
  // Allow collapsible form elements.
  drupal_add_library('system', 'drupal.collapse');

Do you think we should change the fix committed above, and do it the same as this for both module? It looks like 'drupal.collapse' adds the same two .js files, but it might be more future-proof to call this rather than add the two files directly from our code.

GStegemann’s picture

... but it might be more future-proof ...

Even not knowning all the details about Javascript support by Drupal core I would say yes.

jonathan1055’s picture

Status: Fixed » Needs review
StatusFileSize
new631 bytes

Yes, it seems the more proper drupal way to do it. Here's a patch, testing worked fine on my local site, but always worth checking on D.O. aswell.

  • jonathan1055 committed 686da58 on 7.x-1.x
    Issue #618192 by jonathan1055: use drupal_add_library for embed collapse
    
jonathan1055’s picture

Status: Needs review » Fixed

Good to see 394 passes.

GStegemann’s picture

Tested and still works.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.