When you've got facets with "checkboxes and links" enabled on a Solr search page the checkboxes will be displayed when you're logged in.

Anonymous users on the other hand will not see the checkboxes when block caching is enabled. They just see links.
Turning block caching off fixes the problem with the checkboxes, but of course turns block caching off...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cpliakas’s picture

This is probably because the javascript that converts the links to checkboxes is added in the block rendering logic which is not executed when the block is cached. Therefore it is not added when the data is cached.

Thanks for posting,
Chris

cpliakas’s picture

Looks like the technique at http://www.jaypan.com/tutorial/adding-css-and-js-cached-block-drupal-7 should fix the issue.

cpliakas’s picture

Version: 7.x-1.0-rc4 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
1013 bytes

The attached patch moved the JS including into an #attached property.

cpliakas’s picture

Re-thinking location of the #attached so it is in the base widget class.

cpliakas’s picture

Bumping to first page.

cpliakas’s picture

cpliakas’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

CSoft’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work

I still have this problem. To solve it, I changed the line of code in adapter.inc from:

  drupal_add_js($merge_settings, 'setting');

to:

  $build['#attached']['js'][] = array(
    'data' => $merge_settings,
    'type' => 'setting',
  );

It works for me perfectly.

Antonnavi’s picture

I confirm this bug (also reproduce it).
Solution from comment #9 works fine for me.
It also fix issue with soft limit show/hide link disappearing when block cache is enabled.
Thank You CSoft!

GaëlG’s picture

Status: Needs work » Reviewed & tested by the community

This works for me too.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
692 bytes

The code from #9 turned into a patch. There are probably other drupal_add_js() calls, and some drupal_add_css_() calls that need fixing, this should do for now.

frjo’s picture

FileSize
1.24 KB

I had the same issue and patch #12 fixed the problem.

I found a problem with CSS as well and attach a extended patch that takes care of that as well.

kitikonti’s picture

same problem and #13 works for me

eugene.ilyin’s picture

Status: Needs review » Postponed (maintainer needs more info)

Strange, but I cannot reproduce this problem. Maybe it's not actual? I've checked it with the dev version.

brockfanning’s picture

Status: Postponed (maintainer needs more info) » Needs review

@eugene.ilyin: For me patch #13 (thank you!) is still needed even with the latest dev version. Here's what I'm doing to recreate the problem:

  1. On /admin/config/development/performance turn on Drupal's block caching.
  2. On /admin/config/search/search_api/index/.../facets under "Block cache settings" on the "Facets" tab, select "Per role". (depending on your site, this patch might be needed: https://www.drupal.org/node/2657774)
  3. On each facet configuration, choose a "Display widget" of "Links with checkboxes"
  4. Log out of Drupal
  5. Load the search page - note that the checkboxes do appear next to facet items
  6. Re-load the page - the checkboxes do not appear

So the javascript gets loaded the first time, but not successive times - which makes sense if the javascript is not added with '#attached' and the block has been cached.

TLWatson’s picture

Attached an update of patch #13 with line numbers compatible to version 1.5+30-dev.

TLWatson’s picture

Status: Needs review » Closed (outdated)