1

I'm using the Paragraphs and Block field modules to display a list of nodes within the content of a page. This works great while authoring, but as soon as I log out from the administrator account, the node list vanishes from the page. The component is still there, but the content is not rendered.

Here's is the twig template for my block paragraph type:

{%
set classes = [
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
'paragraph--id--' ~ paragraph.id.value,
]
%}

<div{{ attributes.addClass(classes) }}>
  {{ content }}
</div>

Not a lot going on, as you can see.

Does anyone have any experience with the block field module and can walk me through this?

EDIT:

I did some digging into the block field module source, and determined that this is the line of code causing the failure:

if (!$block_instance || !$block_instance->access(\Drupal::currentUser())) {

More specifically, it's the second condition. So for whatever reason, the current user doesn't have access to the block instance unless the current user is an administrator. Does anyone know how to solve this?

EDIT 2: I should probably mention that the blocks I'm trying to show are created by a view. I double checked that the access property on the generated blocks should allow all user roles.

EDIT 3: I did a little more digging, and verified that if I return AccessResult::allowed() from Drupal\views\Plugin\Block\ViewsBlockBase::blockAccess, the problem disappears. So what's happening is the view is saying the block ID is inaccessible for some reason.

EDIT 4: I discovered that setting the "Bypass content access control" permission on all users fixes the issue. However, I'm not sure this is desirable. Is there a way to fix the issue without setting this?

  • Permissions on the block type? – Kevin Dec 12 '18 at 19:38
  • Negative. On my test site, I tried granting anonymous users every permission available, and still nothing shows up. Same for non-admin authenticated users. – Brian Gradin Dec 12 '18 at 19:41
  • Does the anonymous user have access to the nodes being listed? There could be some content access filtering going on. – CG Monroe Dec 12 '18 at 21:13
  • Yes, the nodes are accessible. – Brian Gradin Dec 12 '18 at 21:28
3

FACEPALM

ok, I found the ideal solution. When I looked at my authored nodes in /admin/content, it listed them all as Status: Published. HOWEVER, when I selected all of them, selected "Publish Content" from the action dropdown, and hit "Apply to selected items", suddenly everything appeared in the view block field.

My guess is that something in the database needed to be updated. Seems like a bit of a bug, though - this should have been automatically handled by either Drupal or the block_field module.

Anyway, fixed now.

  • 2
    Indeed, this was an update bug some time ago. I remember that I needed to replace NULLs in block tables to get the blocks displayed again. So simply publishing the blocks again would have worked too, great. – 4k4 Dec 13 '18 at 7:42
0

I too had similar problem, the solution is to grant access to permissions to anonymous user to view paragraph content.

In Paragraphs Type Permissions -> Some Para Test : View content givining permission to anonymous user solves the problem.

  • Anonymous user already had view permissions for all paragraph types in my situation; content was still not visible – Brian Gradin Dec 13 '18 at 18:29

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.