Nico Knoll Posted December 1, 2012 Share Posted December 1, 2012 (edited) Hi,I wrote a new module this evening:Template EditorThis module adds the possibility to edit and rename template files directly from the backend.Requirement:It's important to have this module installed and PW 2.2 running.Download: http://modules.proce...emplate-editor/ Edited April 18, 2015 by Nico Knoll Added the "module" tag and removed it from title. 7 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted December 1, 2012 Share Posted December 1, 2012 Great ! Thank you Nico. Link to comment Share on other sites More sharing options...
Adam Kiss Posted December 2, 2012 Share Posted December 2, 2012 Hah, ACE was on fire this weekend Link to comment Share on other sites More sharing options...
ryan Posted December 2, 2012 Share Posted December 2, 2012 Looks great Nico. Just a couple small suggestions: 1. Rather than using $_POST, it's better to use $this->input->post or wire('input')->post, because it's always possible that $_POST could be affected by the server's magic_quotes setting. 2. When loading or writing to a file, add some extra validation so that someone can't hack through it and start viewing and modifying other files on the server. Example of one way you could do it: $name = $this->config->paths->templates . $this->sanitizer->name(basename($this->input->get->file)); if(!is_file($name)) throw new WireException("Template file not found"); 3. Your execute() method returns a form witha 'delete' action, but I can't see any implementation of that? Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 2, 2012 Author Share Posted December 2, 2012 Ok. Updated it. I used some code of another module of mine for the table. And in this I had a delete function 1 Link to comment Share on other sites More sharing options...
ryan Posted December 4, 2012 Share Posted December 4, 2012 Thanks for the updates Nico! How about posting this to the modules directory? Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 4, 2012 Author Share Posted December 4, 2012 Added it: http://modules.processwire.com/modules/template-editor/ 1 Link to comment Share on other sites More sharing options...
Adam Kiss Posted December 4, 2012 Share Posted December 4, 2012 In the preview, you have 'carfull' in the note, should be 'careful' Link to comment Share on other sites More sharing options...
Soma Posted December 4, 2012 Share Posted December 4, 2012 Be careful if you have carfull. 2 Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 5, 2012 Author Share Posted December 5, 2012 Oh, maybe I should change this Link to comment Share on other sites More sharing options...
Joss Posted December 7, 2012 Share Posted December 7, 2012 Great module! I have one itsy-bitsy problem with it which is to do with the way I have been constructing templates. My "templates.php" files are all in the template directory (obviously) but their inner workings are in a directory called "includes" and I can't get to them. Would there be anyway of being able to access subfolders? Joss 1 Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 7, 2012 Author Share Posted December 7, 2012 Will be definitely in the next update! 2 Link to comment Share on other sites More sharing options...
adrian Posted April 9, 2013 Share Posted April 9, 2013 Hey Nico, I was just testing this out and get several PHP warnings and the template files show up blank. Warning: fread() expects parameter 1 to be resource, boolean given in /xxx/site/modules/TemplateEditor/TemplateEditor.module on line 77 Warning: fclose() expects parameter 1 to be resource, boolean given in /xxx/site/modules/TemplateEditor/TemplateEditor.module on line 78 Notice: Trying to get property of non-object in /xxx/site/modules/InputfieldAceEditor/InputfieldAceEditor.module on line 126 Let me know if I can provide any other debug info. Link to comment Share on other sites More sharing options...
Manol Posted January 3, 2014 Share Posted January 3, 2014 I got all templates blank. Link to comment Share on other sites More sharing options...
Nico Knoll Posted January 3, 2014 Author Share Posted January 3, 2014 Does the module have write access? Link to comment Share on other sites More sharing options...
bbeer Posted February 4, 2014 Share Posted February 4, 2014 I also get a blank Editor screen. I can choose templates, but they are not being displayed. Checked permissions, can't see anything wrong. OS X 10.9.1 Mamp PW 2.3.15 PHP 5.4.3 Link to comment Share on other sites More sharing options...
dragan Posted February 4, 2014 Share Posted February 4, 2014 Try chmod 0664 instead of 0644. Link to comment Share on other sites More sharing options...
bbeer Posted February 4, 2014 Share Posted February 4, 2014 now on 0664 remains blank. Link to comment Share on other sites More sharing options...
bbeer Posted February 5, 2014 Share Posted February 5, 2014 just upgraded MampPro to 2.2 php 5.4.19 mysql 5.3.33 uninstalled TemplateEditor and reinstalled it - same problem. Link to comment Share on other sites More sharing options...
adrian Posted February 5, 2014 Share Posted February 5, 2014 Are there any PHP errors being logged? Link to comment Share on other sites More sharing options...
bbeer Posted February 5, 2014 Share Posted February 5, 2014 Adrian nope, no PHP error at all Link to comment Share on other sites More sharing options...
adrian Posted February 5, 2014 Share Posted February 5, 2014 I just tested this module again myself. The issue is most likely with file permissions. Not that you should necessarily leave it this way permanently, but try chmod'ing everything in your templates folder to 0777. If they are still blank, then you might have fopen disabled somewhere in your php config. Let us know how you go with these two options. Link to comment Share on other sites More sharing options...
bbeer Posted February 5, 2014 Share Posted February 5, 2014 just tried that out now when I set the folder and the templates to 0777 then the templates show up in the editor. So for a quick use this may help, but I think in life environment this is not smart no? Link to comment Share on other sites More sharing options...
adrian Posted February 5, 2014 Share Posted February 5, 2014 It really depends on the owner of those files and also the user that PHP is running as. Chances are you don't need to set them to 777. You should be able to set them to the same setting as the site/assets/ and site/config.php when you installed PW and also the modules directory, if you installed ModulesManager. Basically you need to set it to the lowest level that allows it to work, which would be write access for the owner (assuming the owner matches the php user. Does that make sense? If you are worried about security, you could ask your host about running PHP under SuExec and CGI. Link to comment Share on other sites More sharing options...
bbeer Posted February 5, 2014 Share Posted February 5, 2014 Thanks Adrian it makes sense. It may be a problem of MampPro I think. Guess it will work perfect when on a life Server. 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