We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10298
    • 53 Posts
    From a usability point of view it would be great to have the ability to preview your pages when you right click a document in menu structure. Giving the user the ability to show whats on the page right away.

    I know there is the ability to show this if you turn on the preview in the config settings. With this setting you have to click view and then scroll down the page and your view is limited in the frame.

    Why not add a preview option in the context menu and it will open the selected page up in a new browser window.
      • 18397
      • 3,250 Posts
      I second this although I would prefer it to open the page in the manger like the current preview.
        • 30223
        • 1,010 Posts
        I second the second suggestion smiley
          • 10298
          • 53 Posts
          I still think it is more intuitive to right click and preview a page.

          I’m working for a company where we implement solutions in a professional cms which has this feature in their system and I have met a lot of customers who favor this feature. Mainly those who are not specialists.
          It gives them the ability to quickly view their page as a whole.

          From my point of view it would be better that you could do the same thing in different places in the system. And I think that the preview is a bit limited because it is in an Iframe.

          But anyway it was only a little wish. smiley
            • 25663 MODX Staff
            • 12,272 Posts
            I also would personally use the right-click preview access, even though I turn off site previews. Great idea. (Anyone care to take a quick stab at implementing this?)
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 30223
              • 1,010 Posts
              Ok, a quick stab... quick and dirty. Well, that turned out to be simpler then I thought.

              Here’s a replacement for tree.php

              All I had to do is add an extra few lines in frames/tree.php - shown below from line 493: See the lines with my comments...
              <script type="text/javascript">
              
              // Context menu stuff
              function menuHandler(action) {
                  switch (action) {
                      case 1 :
                          top.main.document.location.href="index.php?a=3&id=" + itemToChange;
                          break
                      case 2 :
                          top.main.document.location.href="index.php?a=27&id=" + itemToChange;
                          break
                      case 3 :
                          top.main.document.location.href="index.php?a=4&pid=" + itemToChange;
                          break
                      case 4 :
                          if(selectedObjectDeleted==0) {
                              if(confirm("'" + selectedObjectName + "'\n\n<?php echo $_lang['confirm_delete_document']; ?>")==true) {
                                  top.main.document.location.href="index.php?a=6&id=" + itemToChange;
                              }
                          } else {
                              alert("'" + selectedObjectName + "' <?php echo $_lang['already_deleted']; ?>");
                          }
                          break
                      case 5 :
                          top.main.document.location.href="index.php?a=51&id=" + itemToChange;
                          break
                      case 6 :
                          top.main.document.location.href="index.php?a=72&pid=" + itemToChange;
                          break
                      case 7 : // Ryan: duplicate document
                          if(confirm("<?php echo $_lang['confirm_duplicate_document'] ?>")==true) {
                                 top.main.document.location.href="index.php?a=94&id=" + itemToChange;
                             }
                          break
                      case 8 :
                          if(selectedObjectDeleted==0) {
                              alert("'" + selectedObjectName + "' <?php echo $_lang['not_deleted']; ?>");
                          } else {
                              if(confirm("'" + selectedObjectName + "' <?php echo $_lang['confirm_undelete']; ?>")==true) {
                                  top.main.document.location.href="index.php?a=63&id=" + itemToChange;
                              }
                          }
                          break
                      case 9 :
                          if(confirm("'" + selectedObjectName + "' <?php echo $_lang['confirm_publish']; ?>")==true) {
                              top.main.document.location.href="index.php?a=61&id=" + itemToChange;
                          }
                          break
                      case 10 :
                      	if (itemToChange != <?php echo $modx->config['site_start']?>) {
                          	if(confirm("'" + selectedObjectName + "' <?php echo $_lang['confirm_unpublish']; ?>")==true) {
                          		top.main.document.location.href="index.php?a=62&id=" + itemToChange;
                          	}
                          } else {
                          	alert('Document is linked to site_start variable and cannot be unpublished!');
                          }
                          break
                      //case 11 : //Raymond: create folder (currently removed)
                      //    top.main.document.location.href="index.php?a=85&pid=" + itemToChange;
                      //    break
              // mod by TobyL: added  preview document in manager
                      // comment/uncomment if you want preview in new window
                      case 12 :
                          //window.open("../index.php?id=" + itemToChange,'previeWin'); //re-use 'new' window
                          //window.open("../index.php?id=" + itemToChange); //open in new window each time
                          top.main.document.location.href="../index.php?id=" + itemToChange; //open in manager
              						break
              				default :
                          alert('Unknown operation command.');
                  }
              }
              
              </script>
              
              <!-- Contextual Menu Popup Code -->
              <div id="mx_contextmenu" onselectstart="return false;">
                  <div id="nameHolder"> </div>
                  <?php
                  constructLink(1, "context_view", $_lang["view_document"], 1,$theme);
              //mod by TobyL: added preview document menu item - requires extra language setting!!
                  constructLink(12, "context_view", $_lang["preview_document"], 1,$theme);
                  constructLink(2, "save", $_lang["edit_document"], $modx->hasPermission('edit_document'),$theme);
                  constructLink(5, "cancel", $_lang["move_document"], $modx->hasPermission('save_document'),$theme);
                  constructLink(7, "copy", $_lang["duplicate_document"], $modx->hasPermission('new_document'),$theme);
                  // constructLink(11, "folder", $_lang["create_folder_here"], $modx->hasPermission('new_document'),$theme);
                  constructLink(3, "newdoc", $_lang["create_document_here"], $modx->hasPermission('new_document'),$theme);
                  constructLink(6, "weblink", $_lang["create_weblink_here"], $modx->hasPermission('new_document'),$theme);
                  ?>
                  <div class="seperator"></div>
                  <?php
                  constructLink(4, "delete", $_lang["delete_document"], $modx->hasPermission('delete_document'),$theme);
                  constructLink(8, "b092", $_lang["undelete_document"], $modx->hasPermission('delete_document'),$theme);
                  ?>
                  <div class="seperator"></div>
                  <?php
                  constructLink(9, "date", $_lang["publish_document"], $modx->hasPermission('publish_document'),$theme);
                  constructLink(10, "date", $_lang["unpublish_document"], $modx->hasPermission('publish_document'),$theme);
                  ?>
              


              , add a new entry in the language file (manager/includes/lang/english.inc.php in my case):
              $_lang["preview_document"] = 'Preview document';


              That’s all. As it is the preview will open in the manager, but that is easily changed if you want to open it in a new window. Just comment out // uncomment the appropriate line in the menuHandler javascript function.


              Well actually I did do a bit more on my local copy. I created a new icon for the "view Document" (as I used the old one for the new preview) and renamed "View document" to "Document Data" in the language file. If you want to do the same then adjust the view document entry in tree.php as follows. The icon I used is in the zip file but it may not fit in with the manager style you’re using... build your own in that case smiley

              <?php
              // existing
              //constructLink(1, "context_view", $_lang["view_document"], 1,$theme);
              // new
              constructLink(1, "context_properties", $_lang["view_document"], 1,$theme);
              ?>
              



              Have fun!

              Oh and before I forget... the icon is a combo of a few icons from the excellent silk set from Mark James http://www.famfamfam.com/lab/icons/silk/

              EDIT Updated.. zip and code above. I forgot the ../ in the path which meant the manager itself opened instead of teh preview. Corrected!
                • 10298
                • 53 Posts
                I know it´s too much to ask for but could this be implemented in the next release.

                I know you should all agree upon this but it would be great.

                I will try my best to answered question from other user have already begun. So you folks can concentrate on the coding part.

                And many thanks TobyL. Very great. I will use it right away
                  • 10298
                  • 53 Posts
                  Im so happy. It is working super.

                  Thanks again

                  you are the champ
                    • 23491 ☆ A M B ☆
                    • 1,056 Posts
                    I wish I used Preview Doc more sad

                    Maybe now I have reason to!!!

                    Thanks for the release
                      Mike Reid - www.pixelchutes.com
                      MODx Ambassador / Contributor
                      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                      ________________________________
                      Where every pixel matters.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      I’ll be committing this momentarily for the 096 release. The choices I think make the most sense. Truly a great and handy addition ... thanks!

                      + Reuse new window for the preview method (this really deserves a configuration parameter)
                      + "Document overview" for the "View document" title
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me