sebafurfaro Posted February 5, 2022 Share Posted February 5, 2022 Hi! I create a directory structure inside the main template directory. So, the templates are inside a directory called pages. /site/template/pages/template1.php /site/template/pages/template2.php But when I create a template from the admin, I get an error saying ProcessTemplate: No new template files were found in: /geointranet/site/templates/*.php. How can that core path be modified? It's possible? Thanks to everyone! Link to comment Share on other sites More sharing options...
Klenkes Posted February 5, 2022 Share Posted February 5, 2022 How about this in your config.php $config->paths->templates = 'YOUR_PATH_TO/site/templates/pages/'; $config->urls->templates = '/site/templates/pages/'; Link to comment Share on other sites More sharing options...
sebafurfaro Posted February 5, 2022 Author Share Posted February 5, 2022 I tried but it still doesn't work Link to comment Share on other sites More sharing options...
3fingers Posted February 5, 2022 Share Posted February 5, 2022 Take a look here: https://processwire.com/blog/posts/pw-3.0.141/#example-1-changing-the-templates-directory 1 Link to comment Share on other sites More sharing options...
sebafurfaro Posted February 5, 2022 Author Share Posted February 5, 2022 Thanks @3fingers I tried to enter this condition if($user->hasRole('superuser')) { $config->setLocation('templates','site/templates/pages/'); } //or the same example if($user->name =='username') { $config->setLocation('templates','site/templates/pages/'); } in both _init.php and config.php, and it still doesn't work. I do not know what I'm doing wrong. Link to comment Share on other sites More sharing options...
szabesz Posted February 5, 2022 Share Posted February 5, 2022 3 hours ago, sebafurfaro said: in both _init.php and config.php, and it still doesn't work You can't do it in those files, use init.php instead, as opposed to _init.php. The latter is just a convention and often used like this: /** * _init.php initializes variables output in _main.php * * This file is automatically prepended to all template files as a result of: * $config->prependTemplateFile = '_init.php'; in /site/config.php. * * Automatic inclusion for any given template can be disabled: * in admin: Setup > Templates > [some-template] -> "Files" tab -> "Disable automatic prepend file". */ In config.php the user is not yet known, as it runs before PW populates the $user and other API variables. Link to comment Share on other sites More sharing options...
sebafurfaro Posted February 7, 2022 Author Share Posted February 7, 2022 I moved the snippet to the init.php file and I get this error: I tried the same example from here https://processwire.com/blog/posts/pw-3.0.141/#new-hookable-templates-gt-filemodified-method And I get the same error. So, I tried this one: $config->setLocation('templates', 'site/templates/pages/'); & this one: $config->setLocation('templates','site/pages/'); For the last one, I move the directory pages into site, but the error is the same. 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