This is a fairly simple problem, I expect. I have created a page that is a Node template (path /node/%node). This template is set to be used in only one Selection Rule: content type "News Item".

Here's the issue: the

Node template

is being used for authenticated users (or at least administrator), but when I view the page as an unauthenticated user, the variant is not used and the page appears unstyled.

I have tried adding the User: role Selection Rule, but the dropdown menu only lists "Logged in user". I have selected all three default User Roles, and still the News Item pages do not show any styling for unauthenticated users.

What could be causing this issue?

Comments

jamesbecker’s picture

I just discovered the solution in case anyone else has this problem:

The page variant was being loaded, but because of the way Drupal renders the DOM elements with different classes depending on whether users are logged in or not, the CSS was not targeting the correct elements for unauthenticated users.

This is due to the bad CSS practice of targeting auto-created Drupal classes and ids via nested selectors instead of assigning my own classes and ids to elements I want to target. Once I rewrote the CSS to target my custom classes and ids, the page shows properly for all users.