Jump to content


Photo

Module: ProcessPreview


  • Please log in to reply
50 replies to this topic

#21 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 234

  • LocationBerlin, Germany

Posted 08 April 2012 - 07:40 AM

Uploaded a new version. It should fix the broken "save" button and the multiple preview windows. Another addition is that you now can see when the preview is loaded because the previe button goes back to green after loading it.

#22 Soma

Soma

    Hero Member

  • Moderators
  • 3,188 posts
  • 1745

  • LocationSH, Switzerland

Posted 08 April 2012 - 10:16 AM

Thanks for the update. The save button now works.

1. When debug mode on, it breaks the admin. Notice shows up and page tree doesn't get loaded.
Notice: Undefined index: id in /.../site/modules/ProcessPreview/ProcessPreview.module on line 31

2. Still, when I open a page, edit something in the text, click "preview" it opens window, but the text change isn't there. When I close the window and hit "preview" again, it shows the updated text. Which means it only works every 2th time I hit "preview" when I change a text. In other words, everytime I change a text I have to open "preview" 2 times to see the change.

@somartist | modules created | support me, flattr my work flattr.com


#23 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 234

  • LocationBerlin, Germany

Posted 08 April 2012 - 10:42 AM

Should work now in the debug mode.

#24 Soma

Soma

    Hero Member

  • Moderators
  • 3,188 posts
  • 1745

  • LocationSH, Switzerland

Posted 09 April 2012 - 11:03 AM

Thanks Nico. Any news to issue #2?

I noticed another problem when submitting a front-end form and have this module installed I get this error:

Error Exception: You must assign a template to the page before setting custom field values. (in /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/core/Page.php line 335)

#0 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/site/modules/ProcessPreview/ProcessPreview.module(38): Page->setFieldValue('_form_id', '35cf3e112fd7061...')
#1 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/core/Wire.php(291): ProcessPreview->changeView(Object(HookEvent))
#2 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/core/Wire.php(229): Wire->runHooks('execute', Array)
#3 [internal function]: Wire->__call('execute', Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/pw-dev/index.php(198): ProcessPageView->execute()
#5 {main}

@somartist | modules created | support me, flattr my work flattr.com


#25 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 234

  • LocationBerlin, Germany

Posted 09 April 2012 - 12:21 PM

Same thing happened to me some minutes ago. I'm not sure why but I'll try to fix it :)

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.

#26 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3114

  • LocationAtlanta, GA

Posted 09 April 2012 - 04:33 PM

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();
}


#27 Soma

Soma

    Hero Member

  • Moderators
  • 3,188 posts
  • 1745

  • LocationSH, Switzerland

Posted 09 April 2012 - 04:42 PM

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.

@somartist | modules created | support me, flattr my work flattr.com


#28 Soma

Soma

    Hero Member

  • Moderators
  • 3,188 posts
  • 1745

  • LocationSH, Switzerland

Posted 01 August 2012 - 12:08 PM

Sorry to bother you, any news on this? :P

@somartist | modules created | support me, flattr my work flattr.com


#29 Soma

Soma

    Hero Member

  • Moderators
  • 3,188 posts
  • 1745

  • LocationSH, Switzerland

Posted 01 August 2012 - 12:26 PM

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.

@somartist | modules created | support me, flattr my work flattr.com


#30 digitex

digitex

    Full Member

  • Members
  • PipPipPip
  • 96 posts
  • 21

  • LocationOntario

Posted 13 August 2012 - 11:20 AM

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.

#31 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 234

  • LocationBerlin, Germany

Posted 16 August 2012 - 08:39 AM

@digitex: Have you tied it out yet? And does it break on your tests, too?

#32 Soma

Soma

    Hero Member

  • Moderators
  • 3,188 posts
  • 1745

  • LocationSH, Switzerland

Posted 29 August 2012 - 02:00 PM

So ... any news on this? :P

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.

@somartist | modules created | support me, flattr my work flattr.com


#33 digitex

digitex

    Full Member

  • Members
  • PipPipPip
  • 96 posts
  • 21

  • LocationOntario

Posted 26 September 2012 - 11:37 AM

@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.

#34 digitex

digitex

    Full Member

  • Members
  • PipPipPip
  • 96 posts
  • 21

  • LocationOntario

Posted 27 September 2012 - 11:11 AM

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=""]\&quot;align_right\&quot;[/url]" src="[url=""]%5C%22/pw/site/assets/files/1058/ce_sticker009.jpg%5C%22[/url]" alt="[url=""]\&quot;\&quot;[/url]" height="[url=""]\&quot;300\&quot;[/url]" width="[url=""]\&quot;300\&quot;[/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

#35 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 234

  • LocationBerlin, Germany

Posted 27 September 2012 - 01:02 PM

OK. I will release a new version in the next week. Because I have holidays - means enough time - then :)

#36 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 234

  • LocationBerlin, Germany

Posted 28 December 2012 - 08:50 AM

I think I found the problem. It was just a TinyMCE thing. Uploaded a new version on GitHub. Should work...

#37 chris

chris

    Distinguished Member

  • Members
  • PipPip
  • 25 posts
  • 21

  • LocationGermany

Posted 18 February 2013 - 12:22 PM

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.



#38 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 644 posts
  • 234

  • LocationBerlin, Germany

Posted 18 February 2013 - 03:04 PM

You're welcome. But I have no idea why "include_once" isn't working... Anyone?



#39 ryan

ryan

    Hero Member

  • Administrators
  • 5,771 posts
  • 3114

  • LocationAtlanta, GA

Posted 20 February 2013 - 07:46 AM

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?



#40 teppo

teppo

    Sr. Member

  • Members
  • PipPipPipPip
  • 388 posts
  • 385

  • LocationFinland

Posted 08 March 2013 - 02:24 PM

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? :)






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users