SebastianP Posted April 24, 2017 Posted April 24, 2017 Hi, I have such a structure in my template folder (ProcessWire 3.0.58): main.php // the template file views/ views/snippets/ In the main.php I include a php-file from the "views"-folder. In this included file are sometimes also files from the "snippets"-folder included. So far, so good:-) But sometimes, after changing und saving a file in the "snippets"-folder, the following error occurs: Fatal error: Call to undefined function wire() in /site/assets/cache/FileCompiler/views/snippets/the_included_file.snippet.php on line 3 But there ist no wrong code. Also changing the file (for example comment out the complete code) does'nt effect something, the error is still the same. Only the manually empty of the "caches"-table in the database fixes the problem and the code runs correctly again. Can someone help me with this? Thank You, regards Sebastian
horst Posted April 24, 2017 Posted April 24, 2017 It seems to be wrong as you call wire() in the global namespace, but you must call it in ProcessWire namespace. What you do is calling \wire(), but it must be ProcessWire\wire(), what would be really weird to add it with every call to a PW function (in a PW programm). Best way would be to add the namespace on top of each *.php file in your template system, (template file, view files, snippet files, ...): <?php namespace ProcessWire; Than it should be valid and functional. 2
SebastianP Posted April 24, 2017 Author Posted April 24, 2017 Thank You horst, it works! Until now I'm not so familiar with namespaces - the man grows with its tasks... 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now