So there are a whole bunch of useful tools in Drupal for changing how a website looks depending on a number of factors, including which page you're on, what roles you have, whether you're logged in or not:

But I can't seem to figure out how to make the following use case work:

  1. Anonymous user visits site

    a. If user has never been to the site before (on this browser/computer), ask whether they are A or B

    b. If user has been to the site before, figure out whether they are A or B (should be easy enough with cookies/session variables)

  2. Change how site looks depending on whether user is A or B

It's really easy once they log in, but how do I tell anonymous users apart?

I tried installing ctools cookie context and ctools session context in the hope that I could use these to provide the necessary hooks for visibility settings in page manager... but visibility settings don't seem to use contexts!

Surely somebody has tried to do this before me? Maybe I am googling the wrong words but I've been at this for several days without a clear idea yet.


1 Answer 1


Typical, no sooner than writing up my question do I find an answer. Though I'd love to hear if there are better ideas.

I discovered that you can use php to check the contexts in visibility settings. I didn't want to do this because I don't want to give the site admin access to php. However, I can make a couple of ctools access rulesets and make those available to the site admin to control visibility.

I haven't tried it yet but I think this will work, as long as the ctools context plugins work as I think they should.

[edit: it worked]

  • This is definitely one way to do it. I have added my own ctools access rules for site admins, and the solution worked well for me. Oct 23, 2014 at 2:37
  • Thank you Patrick, it's very good to know before I try that it has worked before.
    – Darvanen
    Oct 23, 2014 at 3:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.