try changing the include to require.
Try ’global $header’ and ’global $footer’ at the top of your function, and why no semicolon after the include statements?
Use MODx, or the cat gets it!
-
☆ A M B ☆
- 24,524 Posts
$header="assets/files/header.html";
$footer="assets/files/footer.html";
function doFormError($errString) {
global $header, $footer;
include($header);
echo "The form you submitted was not complete.<br /><br />";
include($footer);
exit;
}
Learn about variable scope in PHP functions.
http://www.php.net/variables.scope
Also be aware that MODx snippets are processed through the eval() function. Any output should be gathered into a variable, then finally the variable should be returned. Using echo() or print() statements will work, but may not work as expected. The output may not appear where you thought it should.
Thanks - getting this error, however:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: doformerror() [function.include]: Failed opening ’’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’)
Error type/ Nr.: Warning - 2
File: /home/mysite/public_html/manager/includes/document.parser.class.inc.php(769) : eval()’d code
Line: 127
Mostly harmless.
Try ’$footer=$modx->config[’base_path’]."assets/files/header.html’. Same for $header. Also put ’global $modx;’ at the top of your snippet
Use MODx, or the cat gets it!