Context module is very useful and we use it in some our projects. But sometimes conditions provided by module are not enough for building all required contexts. I created simple module for context 3 branch that adds PHP code condition - user (administrator) can write some PHP code, that returns boolean value.

I'm attaching module code. It would be nice if this functionality will be bundled with context module. You can bundle module as optional or merge module code to main module.

CommentFileSizeAuthor
context_php.zip1.67 KBvgarvardt

Comments

yhahn’s picture

Status: Active » Closed (works as designed)

You're welcome to use this on your own projects, but I would highly recommend simply providing new context condition plugins in a custom module for each custom condition you need. Given that it is simple to extend an existing or base condition plugin for your own needs and this keeps code out of the database, this is the approach I would recommend.

dixon_’s picture

I just contributed vgarvardt's code with some modifications here: http://drupal.org/project/contextphp

But as yhahn says, this kind of condition should only be used in rare cases where a custom condition module doesn't make sense. Keeping code out of the database is always best practice.