zota Posted March 24, 2017 Share Posted March 24, 2017 (edited) Hi! Sorry for being again with a silly question.... Look at that code: <div pw-append="pageContent"> <?php //include("./scripts/_func.php"); //include("./scripts/_func.php"); function renderNav(PageArray $items) { blah, blah pasted code... } if($page->hasChildren) { echo renderNav($page->children); } clumsy isn’t it? Here is the thing: Function renderNav is defined on the file _func.php, so I tried to include _func.php . Then I get a php error - renderNav() is undefined! (what!?grrr) Then, as you see, I duplicate the include line and run. BUT got the php error msg: "Can't redefine function renderNav()" - What!? the f***g bastard already knew renderNav()! Then, I temporary gave up, commented out the include lines and did a copy + paste the renderNav(). And, ugly enough, it works, sure. What's wrong with my include? Thanks EDIT: solved thanks to LostKobrakai remark. I forgot the <?php namespace ProcessWire; ?> thing Edited March 24, 2017 by zota give the solution Link to comment Share on other sites More sharing options...
LostKobrakai Posted March 24, 2017 Share Posted March 24, 2017 _func.php and this file probably do have different namespaces (might be because of the compiler). \renderNav() !== \ProcessWire\renderNav(). Link to comment Share on other sites More sharing options...
zota Posted March 24, 2017 Author Share Posted March 24, 2017 19 minutes ago, LostKobrakai said: _func.php and this file probably do have different namespaces (might be because of the compiler). \renderNav() !== \ProcessWire\renderNav(). You are right (of course you are). I prepended <?php namespace ProcessWire; ?> and works fine. thanks again 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