I’m almost there, but help now required.
Easy option, does anyone know how to stop the templates from caching?
Reason? I am tweaking a template with an external text editor, I have to refresh the site to see the results in the browser.
Here is my snippet.....
if ( !isset($phpfile) || $phpfile == "" ) return "No file specified."; //check if there's a file given.
ob_start();//Start the buffer
include $phpfile; //include
$ob_contents = ob_get_contents();//get contents from the buffer
ob_end_clean();//and kill/delete the buffer
return $ob_contents;//return it to modx
I’m calling it with...
[[Include_Template?&phpfile=`assets/templates/myTemplate/template.php`]]
If I call it like this ( to avoid the cache )
[!Include_Template?&phpfile=`assets/templates/myTemplate/template.php`!]
the rest of the snippets don’t parse.
If I add a variable to the end of the snippet call I get a new version of the template.....
[[Include_Template?&phpfile=`assets/templates/myTemplate/template.php?a=12312312`]]
,but I need to generate a random number to get this more than once.
If I add....
$phpfile .= "?a=".mt_rand(); //to force uncached version of template
... to the snippet code, ModX doesn’t find the template.
Any ideas anyone?