We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21777
    • 9 Posts
    Can it be done?

    norki
      • 22303 MODX Staff
      • 10,725 Posts
      There is not currently a feature for this, no.
        • 21777
        • 9 Posts
        All due respect that’s weak...

        In fact its really not a "preview" as such, this is now a major issue for me as i’m going to have to hack your code to create it...

        Really how hard is it go through the document extract the content and current template variables and chuck them into the template??

        norki
          • 7804
          • 80 Posts
          I don’t think it would be too hard to implement. But it is my understanding that MODx is a developer’s CMS. Most developers have a dev/local build to do modifications and testing before pushing them out live; therefore I doubt this is a super high priority. I know I don’t miss it.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: norki at Mar 10, 2008, 08:22 PM

            All due respect that’s weak...
            With all due respect, thank you for your evaluation. Response and attitude duly noted.

            Quote from: norki at Mar 10, 2008, 08:22 PM

            In fact its really not a "preview" as such, this is now a major issue for me as i’m going to have to hack your code to create it...
            No argument there; it’s not really a preview. And hack who’s code exactly? Last I checked this was an open source project; don’t expect more back than you are willing to put in. So in that sense, you are hacking your own code. And to that effect, it would be appreciated if you contributed this back when you easily knock this out, seeing as how we offer the project for your use at no cost.

            Quote from: norki at Mar 10, 2008, 08:22 PM

            Really how hard is it go through the document extract the content and current template variables and chuck them into the template??
            Let us know how easy it is to accomplish...
              • 21777
              • 9 Posts
              All that really has to be done is create a duplicate saved document and then display it without altering the original:

              Here is a hack which can do this for now:

              Create a "preview document" my one had id=128

              in mutate_content.dynamic.php:

              function realPreview() {
              document.forms[’mutate’].elements[’id’].value=128;
              document.forms[’mutate’].elements[’alias’].value=’’;
              document.forms[’mutate’].elements[’pagetitle’].value=’Preview Document (DO NOT DELETE!)’;
              var f = document.forms[’mutate’];
              documentDirty=false;
              f.target = "_blank";
              f.refresh_preview.value=1;
              f.save.click();
              f.target=’’;
              f.refresh_preview.value=0;
              document.forms[’mutate’].elements[’id’].value=’<?php echo $content[’id’];?>’;
              document.forms[’mutate’].elements[’alias’].value="<?php echo stripslashes($content[’alias’]);?>";
              document.forms[’mutate’].elements[’pagetitle’].value="<?php echo htmlspecialchars(stripslashes($content[’pagetitle’]));?>";
              }
              seems to work...

              norki
                • 21777
                • 9 Posts
                Let me correct my attitude aside from this minor thing... modx is really very nice.

                norki
                  • 25663 MODX Staff
                  • 12,272 Posts
                  Thanks norki, that looks like a great start. smiley

                  I think for this to be universally useful a few things would need to be addressed, such as the need to extend the code above to copy over the template and any (arbitrary number and type of) TVs and their values as well. If a TV or any snippet contained calls to a parent document or any other ancestor doc for that matter, and the preview document was also not at the same level of the tree heirarchy, then you’d similarly run into breakdowns of the preview accuracy (which also brings to mind that menu systems wouldn’t accurately reflect the location for menus that dynamically present a "you are here" state). And finally, what would happen in multi-editor workflows where many updates are going on simultaneously?


                    Ryan Thrash, MODX Co-Founder
                    Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me