It appears that I can't use module_load_include in the PHP Validate Code of a contexual filter.

Steps:
1. Display the view, which is included via a block, on page https://[server domain]/projects-planning/projects/[name-of-project-with-hypens-all-lower-case] and verify there is content
2. Copy the code from PHP validate code to new file /docroot/sites/all/modules/[my site module folder]/includes/[my include name].inc
3. Push the new file to the site via git add/commit/push
4. On https://[server domain]/admin/structure/views/view/[name of view]/edit, click the existing Content:nid contextual filter (that is I am changing the master, which doesn't have any overrides on contextual filter)
5. In the PHP validate code field, replace the code (which I copied in step 2) with
module_load_include('inc', '[my site module folder]', 'includes/[name of file created in step 2 without the .inc]');

The code in question is:

$st = arg(0) . "/" . arg(1) . "/" . arg(2);
$np = explode('/', drupal_get_normal_path($st));
if (!empty($np[1])) {
$handler->argument = $np[1];
return TRUE;
} else {
return FALSE;
}

Workaround: If I restore the code to the PHP validate code field, the content is restored to the page.

I'm trying to have a best practice of keeping all PHP code (except for module_load_include) in the codebase. Is there any way for me to accomplish that here?

Comments

MustangGB’s picture

Status: Active » Closed (outdated)

Closing this as outdated, feel free to re-open with updated details if it's still a problem in the latest release.