Search code examples
drupaldrupal-panels

Drupal - Panels - use variants according to NID


I'm using Panels to overwrite node template (node/%node). I would like the system to use specific variant when a node is loaded. E.g. node 123 should use variant A and node 223 should use variant B. There isn't an option for me to determine that under Selection rules, I'm wondering if I should use PHP Code, and if I do, how should I go about writing the code?

I'm aware of the option of using Panels Node, but by using it, there is no easy way to edit the node thus rendering it a less than desirable choice.


Solution

  • In this case the easiest thing is probably to throw in some PHP code. It would be prettier to make an extension to the Panels selection rules, but this might be a bit overkill in this case.

    Anyways something like

    return arg(1) == 123;
    

    should do it.

    Your problem is probably Drupal/Panel cache. I just tested it, and it works fine.