suntrop Posted August 2, 2021 Share Posted August 2, 2021 (edited) It is quite some time since I launched my last PW project and can't remember/find if I forgot something. The functions API in my /site/config.php is set to true. I have just installed a blank new PW project. But every call ends with an error. <?= var_dump($config->useFunctionsAPI); page()->get('title'); ?> bool(true) Darn… Fatal Error: Uncaught Error: Call to undefined function page() in site/templates/_main.php:15 The config setting is correct, but still it is not working. Did I miss something? I just installed 3.0.165 Edit: Just noticed it works fine in template files like basic-page.php and home.php but not in _main.php (which gets appended) Edited August 2, 2021 by suntrop Added more info at the end Link to comment Share on other sites More sharing options...
horst Posted August 3, 2021 Share Posted August 3, 2021 Do you have a correct namespace set in top of your _main.php? Otherwise you may test in your testpage the following: <?php var_dump(function_exists('page')); var_dump(function_exists('ProcessWire\page')); Link to comment Share on other sites More sharing options...
suntrop Posted August 3, 2021 Author Share Posted August 3, 2021 Yes, I had set the namespace properly. Strange part now, I installed another PW instance, a couple of hours ago, and first thing I tested was the Functions API in a newly created _main.php. It worked. I did a lot of testing and lastly just copied the file itself. That file worked (was just an echo page()->id). I copied the markup again and everything was like before, but it now works. I have no idea what was wrong with the other file. Just tested with different encodings, BOM, w/out namespace etc. but nothing to reproduce the error. Link to comment Share on other sites More sharing options...
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