ryan Posted April 9, 2012 Share Posted April 9, 2012 Nico, thank you for the update. I have a couple suggestions. First would be to use a more unique fieldname for the 'id' so that this module isn't running every time there is an 'id' field in $_POST. That's used by plenty of things other than page editing, so potential for this module running when it shouldn't. An example would be 'ProcessPreviewID'. So here's how you would add your hook in the init() method: if(isset($_POST['ProcessPreviewID'])) $this->addHook('ProcessPageView::execute', $this, 'changeView'); Now when your changeView function executes, you know there's little chance it's not getting involved when it shouldn't. I also recommend modifying your changeView() function to sanitize the ID and validate that the page is editable, for security. Here's how I rewrote your function (though have not tested): public function changeView(HookEvent $event) { $page = $this->pages->get((int) $_POST['ProcessPreviewID']); if(!$page->editable()) return; foreach($_POST as $key => $value) { if($page->fields->has($key)) $page->setFieldValue($key, $value); } $page->status = Page::statusOn; $event->return = $page->render(); } Link to comment Share on other sites More sharing options...
Soma Posted April 9, 2012 Share Posted April 9, 2012 And to issue#2: Which browser are you using and which system? Because I don't have this problem with Chrome on Mac OS X. I'm also using Chrome 18.01... on Mac OS X 10.6.8 Edit: actually after trying again it stopped working. When clicking "preview" it does nothing. This is from js console when clicking: POST http://test.ch/about/ f.support.ajax.f.ajaxTransport.sendJqueryCore.js:18 f.extend.ajaxJqueryCore.js:18 (anonymous function)/processwire/page/edit/?id=1001:634 f.event.handleJqueryCore.js:17 f.event.add.i.handle.k I have the latest and cleared cache. Same when using FF. Link to comment Share on other sites More sharing options...
Soma Posted August 1, 2012 Share Posted August 1, 2012 Sorry to bother you, any news on this? Link to comment Share on other sites More sharing options...
Soma Posted August 1, 2012 Share Posted August 1, 2012 While testing this again, noticed a problem with my flourish include in the header.inc. Defines function like this: <?php // include flourish lib function flourish_loader( $class_name ) { // Customize this to your root Flourish directory $flourish_root = wire("config")->paths->root . '.libs/flourish/'; $file = $flourish_root . $class_name . '.php'; if (file_exists($file)) { include $file; } } spl_autoload_register( 'flourish_loader', true ); When the preview popup loads, it throws an Fatal Error, that the function is already defined. Somehow it renders or loads the page 2 times it seems. Not sure where this comes from, and if this could lead to problems elsewhere too. However to avoid it one can write the flourish include like this (for reference) <?php if( !function_exists(flourish_loader)){ function flourish_loader( $class_name ) { // Customize this to your root Flourish directory $flourish_root = wire("config")->paths->root . '.libs/flourish/'; $file = $flourish_root . $class_name . '.php'; if (file_exists($file)) { include $file; } } } spl_autoload_register( 'flourish_loader', true ); Still my #2 still persists. When I change text on page and hit preview it doesn't show changes. Only after I close and click preview again it show the changed text. Link to comment Share on other sites More sharing options...
digitex Posted August 13, 2012 Share Posted August 13, 2012 Is there any word on this? A preview without save would be ideal. Currently, the view page doesn't open in a new window and doesn't reflect changes without saving first, which puts potential errors out there for the world to see. Worse, if you don't save first, by the time you realise your edits are not showing, you've lost them all since it doesn't open a new window. I'd like to see about adding a target="_blank" to the view button in the interim but preview would be far better. If it can be made to work fairly consistently across all browsers. If you're still working on this Nico, thanks for the effort and keep it up. Link to comment Share on other sites More sharing options...
Nico Knoll Posted August 16, 2012 Author Share Posted August 16, 2012 @digitex: Have you tied it out yet? And does it break on your tests, too? Link to comment Share on other sites More sharing options...
Soma Posted August 29, 2012 Share Posted August 29, 2012 So ... any news on this? Again, it doesn't show any changes made when I use the preview button. Only when I open the preview a second time it shows the changes. I don't know what the problem is but it was always like this and doesn't let me use this module. I use OSX and Chrome and in FF it's the same. Link to comment Share on other sites More sharing options...
digitex Posted September 26, 2012 Share Posted September 26, 2012 @digitex: Have you tied it out yet? And does it break on your tests, too? Sorry Nico, I wasn't ignoring you I just haven't been back to check threads in the forum for a while. I haven't tested this yet. I will look into it this week and let you know if I have the same results as Soma. Link to comment Share on other sites More sharing options...
digitex Posted September 27, 2012 Share Posted September 27, 2012 OK I tested this and i get the same problem as Soma, I click preview, window opens, displays the page contents but unedited. Close the window, click preview again and it opens and displays the edits. However... It also adds some funky characters to the page body: <h3>SPREAD AWARENESS!</h3><p><img class="[url=""]\"align_right\"[/url]" src="[url=""]%5C%22/pw/site/assets/files/1058/ce_sticker009.jpg%5C%22[/url]" alt="[url=""]\"\"[/url]" height="[url=""]\"300\"[/url]" width="[url=""]\"300\"[/url]"></p> Sort of like it's trying to escape the quote characters. I'm using FF 14.0.1 and MacOS 10.6.5 Link to comment Share on other sites More sharing options...
Nico Knoll Posted September 27, 2012 Author Share Posted September 27, 2012 OK. I will release a new version in the next week. Because I have holidays - means enough time - then 3 Link to comment Share on other sites More sharing options...
Nico Knoll Posted December 28, 2012 Author Share Posted December 28, 2012 I think I found the problem. It was just a TinyMCE thing. Uploaded a new version on GitHub. Should work... 3 Link to comment Share on other sites More sharing options...
Chris Posted February 18, 2013 Share Posted February 18, 2013 the preview seems not to show parts of the site template that are included with include_once. it's easy fixable with changing include_once to include. i just like to leave this as a sidenote, if someone got the same issues like me ( no header.inc/footer.inc ) thank you for this nice plugin. it's realy something customers like to use and know from other systems. Link to comment Share on other sites More sharing options...
Nico Knoll Posted February 18, 2013 Author Share Posted February 18, 2013 You're welcome. But I have no idea why "include_once" isn't working... Anyone? Link to comment Share on other sites More sharing options...
ryan Posted February 20, 2013 Share Posted February 20, 2013 You're welcome. But I have no idea why "include_once" isn't working... Anyone? If include() works and include_once() doesn't, then it means the file was already included, so it got skipped the second time. The question is, when/where was it included? Link to comment Share on other sites More sharing options...
teppo Posted March 8, 2013 Share Posted March 8, 2013 Nico: I'm a bit late to join this party, but.. thanks for making this module! Was looking for exactly something like this from modules directory just last week -- how 'bout adding this there too? 1 Link to comment Share on other sites More sharing options...
Nico Knoll Posted March 8, 2013 Author Share Posted March 8, 2013 Oh, I thought I did that already... Here it is finally: http://modules.processwire.com/modules/process-preview/ 2 Link to comment Share on other sites More sharing options...
Soma Posted March 11, 2013 Share Posted March 11, 2013 Thanks for adding Nico. Wanted to mention an notice that shows up when in debug mode. Always turn on debug mode when developing. <b>Notice</b>: Undefined index: id in <b>/xxx/site/modules/ProcessPreview/ProcessPreview.module</b> on line <b>31</b><br /> And then also the Page Tree doesn't load when debug mode in on.. Link to comment Share on other sites More sharing options...
Nico Knoll Posted March 11, 2013 Author Share Posted March 11, 2013 Thanks for adding Nico. Wanted to mention an notice that shows up when in debug mode. Always turn on debug mode when developing. <b>Notice</b>: Undefined index: id in <b>/xxx/site/modules/ProcessPreview/ProcessPreview.module</b> on line <b>31</b><br /> And then also the Page Tree doesn't load when debug mode in on.. Hey I looked at the code and saw that I still was using $_POST and $_GET. Now I replaced them by $this->input->post and $this->input->get and tried it in debug mode. Everything seems to be working. I updated it on GitHub some seconds ago. Link to comment Share on other sites More sharing options...
Soma Posted March 12, 2013 Share Posted March 12, 2013 Thanks Nico! It's still 2.0.5 on http://modules.processwire.com/modules/process-preview/ 1 Link to comment Share on other sites More sharing options...
lpa Posted March 18, 2013 Share Posted March 18, 2013 Found problems moving pages when ProcessPreview is in use: http://processwire.com/talk/topic/3089-moving-pages-hanging/ Could you check it? Link to comment Share on other sites More sharing options...
Nico Knoll Posted March 18, 2013 Author Share Posted March 18, 2013 Okay localized the error by commenting out some lines. It's line 41: $return = $page->setOutputFormatting(true)->render(); But the problem is that I don't understand ow this can influence the pagetree because it won't be executed... Maybe someone has an idea? Link to comment Share on other sites More sharing options...
Soma Posted March 18, 2013 Share Posted March 18, 2013 Not really sure what it has to do with ProcessPageView but sort is ajax based and since it's calling a process execute page there might be something triggered. For now I think adding a check in the start of that function would solve it. if($this->config->ajax) return; But also would like to understand more why. Ryan? Link to comment Share on other sites More sharing options...
Soma Posted March 18, 2013 Share Posted March 18, 2013 Especially I'd like to see if the way you do hook ProcessPageView is right without additional checks for if on front or backend. Especially when making hooks like this you want to make sure everything works correct and doesn't have unwanted effects as in the past of this module Link to comment Share on other sites More sharing options...
Soma Posted March 18, 2013 Share Posted March 18, 2013 Ok, testing for ajax does solve the problem but the preview doesn't work anymore (shows no changes). Adding this instead: public function changeView(HookEvent $event) { if($this->page->process == "ProcessPageSort") return; Does make it work, and solves the sort problem. But still you add with $this->addHook("ProcessPageView::execute") which will be execute by every page view (admin and front-end) it seems it's sensitive to everything that happens in PW even process page sort. Replace the above with exit(); and you won't be able to view something. Link to comment Share on other sites More sharing options...
Soma Posted March 19, 2013 Share Posted March 19, 2013 Yet another issue: http://processwire.com/talk/topic/866-image-upload-weird-issue/?p=30451 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