Adam Kiss Posted December 3, 2013 Share Posted December 3, 2013 Hey all, I am developing some custom Process modules for a website, and in those i'm including_once some files. Now, I didn't want the editor to have all the unused parts of website (users, modules, etc.) in his user interface, so I created limited role, and added to both the editor and administrator same permission, which was then used with the Process module. public static function getModuleInfo() { return array( 'permission' => 'internal-tools' ); } But what's curious – and I can't think of why it happens – is that it seems, that when the module is loaded, different roles (users) have different path set up as CWD(). For admin, it's: /.../www.domain.com/site/templates/ For editor, it's: /.../www.domain.com/ Now, I can simply not use relative path to include file, but rather a realpath/dirname(__FILE__) combination, but I am not sure whether this is wanted behavior, or some kind of mis-setup I did. Any thoughts are welcome. Link to comment Share on other sites More sharing options...
ryan Posted December 11, 2013 Share Posted December 11, 2013 The root is the execution path, but ProcessWire changes it to /site/templates/ when executing a template file. Not sure exactly what would account for the difference here, but it looks like the different access control is resulting in one of the instances occurring while a template is being executed, and and another while it isn't. From within a module file, you wouldn't want to use relative paths like. You'd definitely want to use an absolute path to your resource. Lets say you wanted to include() a file that's in /site/templates/, you'd do this: include($this->config->paths->templates . 'your-file.php'); Or if you wanted to include a file in the current module's directory, you'd do this: include($this->config->paths->YourModuleClassName . 'your-file.php'); // this also works: include(dirname(__FILE__) . '/your-file.php'); 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