In short I'm attempting to output data from Drupal to Word using PHPWord and a standalone Drupal script that pulls from the Drupal site/database. However the standalone Drupal script conflicts with PHPWord, so as a work around...
I've created a standalone Drupal page to carry out an EntityFieldQuery to return multiple nodes. Here's the essence of that script...
<?php
$drupal_root = $_SERVER['DOCUMENT_ROOT'];
chdir($drupal_root);
define('DRUPAL_ROOT', getcwd());
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
drupal_page_is_cacheable(FALSE);
$reference = 'OURREFERENCE'
$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'CONTENT_TYPE')
->fieldCondition('field_reference','value', $reference, '=')
->execute();
if(count($result) > 0){
$nids = array_keys($result['node']);
$nodes = node_load_multiple($nids);
}else{
$output = 'Error creating the word document';
}
return $nodes
?>
I'm trying to include the output of this PHP script in another PHP script like this:
<?php
include("competition_data.php");
?>
However because its an include it simply adds the code into this second page and executes it as part of that page, instead I'd like to execute it and return the array of nodes to the second script.
I've also tried EXEC and SHELL_EXEC following some other questions on Stack.
Any help would be appreciated.
Additional Info The issue I have is down to a conflict caused by the included file. I attempted to put the entire script into a single standalone PHP script including the Drupal connection. However this caused a conflict between PHPWord and Drupal's module.inc therefore my next logical step was to seperate the two parts - a script that queries Drupal and outputs JSON that then I'm able to pull into the second PHP script to work on the PHPWord side of things. In my case a predefined word template where I'm replacing variables within the text for variables held within the now Json string. Sorry I left the json out above as I only wanted to convey the include issue. So In short I'd like to call the first PHP script within the second file - but it would need to execute and return its output rather than run as an addition to the second file.