6

I have recently been looking for module that will allow you to preview the page you are creating, in real time as you are creating it (just like SE questions). I came across the live module, but I realized that it was only for drupal 5 and 6. Is there a similar module that allows you to preview your page live, for Drupal 7?

3

I've given this problem some thought (actually began writing code for a D7 live preview), and as it happens I simply don't think live preview is that simple in Drupal.

Live preview on SE.sites is efficient because there are no AJAX requests going on for rendering the preview. In a nutshell SE.sites merely clone the text from the editor textarea into the preview div, where CSS classes are applied to it. In reality there is more processing happening in the background as the text that you enter must be converted into real markup (ie, when using lists).

In Drupal however there can be a lot of pre-processing of text, depending on what modules you have enabled. For instance, take the <!--break--> control sequence (which is part of core behavior, btw). Does that really mean something in HTML? No, it must be preprocessed by Drupal into teaser and full body text snippets; take the CKEditor and the IMCE modules for example, they also depend on preprocessing text to translate special markup for images into actual <img> tags.

What that means is that in order to have a live preview that is faithful to it's final state, you must run whatever text you enter through a number of hooks, preprocessors, renderers and what have you. Else your live preview will not represent the final product. Therefore, having a faithful Live Preview in Drupal would mean sending an AJAX request to the back-end every time the editor in the front-end is updated. And then, you can ask yourself the question? Is this scalable? That would probably depend on your use case. If you want Live Preview for a site with a big editorial team (think www.nowpublic.com, a Drupal site), the answer would probably be no. But maybe if it is for a small site, with a few visitors or editors, then the answer would be maybe, but it still raises performance concerns.

So taking those points into consideration, what kind of preview would you be looking for? Slow & Faithful or Fast and Unfaithful?

0

Didn't test it, but ajax_markup seems to fit your needs, and it's stable.

  • I installed ajax_markup, but it doesn't provide a preview underneath like SE does, it turns the help button into a preview button, so you click it, and it doesn't require a page-reload, but other than that, it's not that much different from just using the regular preview button. – Ephraim May 3 '12 at 21:47
0

I have started development of a module - Live preview which might be more along the lines of what you're after:

This module provides a more comprehensive, genuine and interactive version of the built-in node preview feature.

The live preview feature requires JavaScript; if JavaScript is disabled it will not apply its triggers, effectively retaining the built-in preview.

It hasn't yet reached a stable release, but it's worth checking out (-dev version should work just fine).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.