I have a button that I would like to show to anonymous users only on pages with a path matching en/*.

    /* English Button */
    {
      title: 'English',
      path: 'en/home_anon',
      options: {
        attributes: {
          'title': 'English',
          'data-icon': 'star',
          'class': 'ui-btn-right',
        }
      },
      pages: {
        value: ['en/*'],
        mode: 'exclude'
      },
     roles: {
        value: ['authenticated user'],
        mode: 'exclude',
      }
   },

Anonymous, en/* path: Appears (* incorrect behavior)
Anonymous, non en/* path: Appears (correct behavior)
Authenticated, en/* path: Does not appear (correct behavior)
Authenticated, non en/* path: Does not appear (correct behavior)

If I remove the roles: exclude authenticated user part, then the exclusion by path works properly. So, it appears that somehow the roles: exclude authenticated user is causing the button to be included even if the path check indicates the button should be excluded.

Comments

tyler.frankenstein’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

I believe this is by design, as I based it on how Drupal handles block visibility, but I don't remember for sure. To verify, will you please create a custom Block in Drupal, then set its visibility rules for Pages and for Roles, and see how Drupal reacts to this. I'm fairly certain Drupal only picks one of these settings for the visibility rules.

UPDATE: You can declare a callback function to tweak a block's visibility settings: http://drupalgap.org/node/168#access_callback

ptmkenny’s picture

Status: Postponed (maintainer needs more info) » Active

I'll look into this more, but for now, note that Drupal only allows blocks to be limited by role (there is "include" but no "exclude").

As indicated by this UI text:

Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.

So as far as D7 is concerned, there is no "exclude" option.

jomarocas’s picture

ok i have the same issue, when i put roles and pages,but also i need include this option in my popup options
i try many options but access callback dont work good, any other options for this

i have duplicate popups in user login, one works but when i go to others page that i no specified, fails show me two user login, one works, but the other no make nothing

this is the block
    user_menu_anonymous: {
      //access_callback: 'custom_module_access_callback',
      pages: {
        value: ['home', 'menu-principal'],
        mode: 'exclude'
      },
       roles: {
         value: ['anonymous user'],
         mode: 'include',
       }
    },

this in regions options

    {
      //access_callback: 'custom_module_access_callback',
       pages: {
         value: ['home','menu-principal'],
         mode: 'exclude'
       },
      roles: {
        value: ['anonymous user'],
         mode: 'include',
      },
      options: {
        popup: true,
        popup_delta: 'user_menu_anonymous',
        attributes: {
          'class': 'ui-btn-right',
          'data-icon': 'user'
        },
      },
    },

tyler.frankenstein’s picture

Status: Active » Postponed (maintainer needs more info)

The access_callback is the way to go for any complex visibility needs. It works better than pages and roles visibility IMO. Please provide more info about the visibility you are looking to accomplish.