We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16892
    • 107 Posts
    Is it possible to use a link for PrintDoc instead of the image? Is it possible to call the snippet in the body of the document?

    If so, how?

    Thanks!
      • 27807
      • 11 Posts
      hello,

      I litle problem,

      I want to print the page when the popup loads.

      so I did’t the following:
      Open printpage witch fsck editor
      click on source and add these rules:

      <body onLoad="window.print();">
      <font face="Arial"><font face="Arial">[[PrintDoc? &amp;print_doc=`124` &amp;tpl=`Print`]]</font></font>

      save the document.

      This works fine, but when i edit the page again witch fsck editor the first rule (<body onLoad="window.print();">) has been deleted.
      How does i solved this problem?



        • 18000
        • 1 Posts
        Hi,
        I have a Thankyou Page who is shown after send a message with the eForm, the "Thanyou-page" is a Chunk-template here how to call it.
        [[eFormEvent]]
        [!eForm? &formid=`kostenBer` &sendirect=`1` &eFormOnBeforeMailSent=`neuerWert` &tpl=`kostenForm` &report=`kostenAusgabe` &noemail=`1` &thankyou=`kostenAusgabe`!]
        Now when I want to print this Page, the Page before will be print.
        How can I print the "thankyou- Page" ?

        Sorry my english is not the best. smiley
          • 30457
          • 4 Posts
          First of all i want to thank to tihs snippet.

          I ve done all the introductions. the snippet works in firefox 3 but in ie7 not.
          When i created a folder and a doc under it, ie7 puts the print-doc.html under the folder and modx 404 page comes to screen.

          can you help me?

          [b]SOLVED:[/b] I ve put [(site_url)]/ code before [~$print_doc~]&p_ ...... in PrintDoc snippet.
          so the new line is
          $jslink = "javascript:void window.open(’[(site_url)]/[~$print_doc~]&p_docid=$modx->documentIdentifier’, ’win2’, ’status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=500,height=500,directories=no,location=no’);";
            • 30564
            • 60 Posts
            I note herein that more that a few found themselves only able to ’print’ the first page. In my case I was puzzled as to why this snippet worked in manager mode but not as a user, then realized that the mode treated page status differently.

            [Solution] Ensure the print page is set to container & published whilst excluded from menu.

            In passing, it should be noted that the print page is also a snippet so should be set not to cache to ensure the current page is loaded.

            Regards
            PS To OP a very neat snippet thanks.
            PPS The javascript output includes an index.php whereas on the originator’s site it does not.
            e.g. javascript: window.open(’index.php?id=43&p_docid=3’,’win2’, status=no, toolbar=no, scrollbars=yes, titlebar=no, menubar=no, resizable=yes, width=500, height=500, directories=no, location=no’);

              • 28528
              • 31 Posts
              I know this is a really old thread and I’m not holding out much hope of getting a response but this snippet does exactly what I need apart from the printable pop-up page repeats the printable content 10 times! I’ve read and re-read the code over and over but I just can’t see what the problem might be.

              Steve

              if(isset($print_folders) && $print_folders == 1) 
                  $print_f = ($modx->documentObject['isfolder'] == '1') ? 1 : ''; 
                  
              // if the print document, which is the page where the document to be printed will be rendered, is not set than return nothing.
              if(isset($print_doc)) $print_doc = $print_doc; else return "<br />\n No documet Id set for the Printing page.";
              
              
              /*****************************************************************************/
              
              // if the get or post variable of p_docid is not set then show the link. otherwise display the document
              if(isset($_GET['p_docid']))
              {    
                  $q = $modx->db->select('*', $modx->getFullTableName('site_content'), 'id = '.(int)$_GET['p_docid'].' LIMIT 1');
                  $rec = $modx->db->getRow($q);
                  
                  // change the document title
                  $modx->setPlaceholder('documenttitle', $rec['pagetitle'].' |');
              	    
                  $template = '
                      <table border="0" width="100%" align="center">
                      <tr>
                          <td align="left" style="padding-bottom: 5px"><div class="title">[+longtitle+]</div></td>
                      </tr>
                      <tr>
                          <td align="left"><div style="font-size: 9px; padding-bottom: 20px; padding-left: 20px">[+description+]</div></td>
                      </tr>
                      <tr>
                          <td>[+content+]</td>
                      </tr>
                      </table>
                  '; 
                  
                  // if a chunk is submitted than this will be used as a template. Remember that [+content+] is the placeholder which will be replaced
                  if(isset($tpl) && isset($tpl) != '')
                  {
                      $c = $modx->db->select('name', $modx->getFullTableName('site_htmlsnippets'), "name = '$tpl'");
                      if(count($modx->db->getRecordCount($c)))
                          $template = $modx->getChunk($tpl);
                  }
                  
              	// Parse Snipets
              	if(preg_match_all('/\[\[([a-z\-_\+\. ]+)\]\]/i',$template, $matches))
              		foreach($matches[1] as $match)		
                  			$template = preg_replace("/\[\[([a-z\-_\+\. ]+)\]\]/i", $modx->runSnippet($match, array('docid' => $_GET['p_docid'])), $template);
                  // Parse Chunks
              	if(preg_match_all('/\{\{([a-z\-_\+\. ]+)\}\}/i',$template, $matches))
              		foreach($matches[1] as $match)		
                  			$template = preg_replace("/\{\{([a-z\-_\+\. ]+)\}\}/i", $modx->getChunk($match), $template);		
                  
                  // Parse Placeholders
                  foreach($rec as $ph => $val)
              		$template = str_replace("[+$ph+]", $val, $template);
                  $content = $template;
                  
                  // add the JScrip to print the page automatically
                  $js = '<script type="text/javascript"> window.print() </script>';
                  //$modx->regClientScript($js);
              }
              // display the link to print
              else
              {
                  $jslink = "javascript:void window.open('[~$print_doc~]&p_docid=$modx->documentIdentifier', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=500,height=500,directories=no,location=no');";
                  $content = '<a href="'.$jslink.'" title="Print this document"><img src="assets/images/printButton.png" alt="Print" title="Print this document" border="0" /></a>';
              }
              
              return $content;
              

                • 3749
                • 24,544 Posts
                I’m going to guess that you’re putting a tag for the snippet in the page content. Each time the page is rendered in the content, it executes the snippet again recursively. Could that be it?
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 28528
                  • 31 Posts
                  Brilliant grin

                  Thanks BobRay wink
                    • 29877
                    • 35 Posts
                    I would like to utilize this on a site that I am working on. I however find the instructions / implementation of this extremely confusing. The directions are not very clear in my opinion. I’ve made an attempt to get this up and running on my site and it’s not quite there yet.

                    Does anyone have a demo of this in action where I can see how it behaves?
                      • 3749
                      • 24,544 Posts
                      Quote from: thomasgrant at Sep 11, 2009, 09:28 AM

                      I would like to utilize this on a site that I am working on. I however find the instructions / implementation of this extremely confusing. The directions are not very clear in my opinion. I’ve made an attempt to get this up and running on my site and it’s not quite there yet.

                      Does anyone have a demo of this in action where I can see how it behaves?


                      I think most of us use CSS and a JavaScript button to print pages. Here’s an example where the button prints a coupon from an image on the page and nothing else:

                      CSS link:
                      <link rel="stylesheet" href="print.css" type="text/css" media="print" />


                      print.css:
                      body {visibility:hidden;}
                      .print {visibility:visible;} 
                      
                      #header img {
                      display:none;
                      }
                      body #FOOTER {
                      display:none;
                      }
                      body p {
                      display:block;
                      margin-left:60px;
                      }
                      body form {
                      display:none;
                      }
                      body hr {
                      display:none;
                      }
                      body img {
                      margin-left:100px;
                      }
                      
                      .coupon {
                      margin-left:10px;
                      margin-top:30px;
                      }
                      .coupon form {
                      margin-left:250px;
                      margin-top:30px;
                      margin-bottom:30px;
                      
                      }
                      #footer {
                      display:none;
                      }
                      
                      #footer img {
                      display:none;
                      }



                      Button:
                      <div class="dontprint">
                              <form><input type="button" value=" Print this coupon "
                      onclick="window.print();return false;" /></form>
                          </div>
                      </div> 
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting