We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21054
    • 78 Posts
    A client wants a "print" button on the top right of every page, so that it pops up a new window with the content written presented in plain text for printing.

    I have it working fine using the GetField snippet but there is a problem. Whenever the content has a snippet call, it doesn’t evaluate, but instead shows the text of the snippet.

    Here is a step by step flow of what I’ve done.

    1.

    The page looks like this:



    The part starting "Recent media statements" is actually generated by a custom Snippet called "media" (this is just an example, the problem exists for any Snippet call):

    [!media? &action=`summary` &numarticles=`5` !]

    2.

    The "print" button code looks like this:

    <a href="[~[!GetField? &docid=`[*id*]` &field=`id`!]~]#" onclick="popwindow(’[~178~]&pageId=[*id*]’, ’[*title*]’)">
    <img src="_images/print.png" title="Print this page" alt="Print this page" /></a>


    I’m basically passing the ID of the page through its address as a variable (pageId) so that I can use it later on the pop up window.

    3.

    This is the body part of the pop up page template:

    <body onLoad="window.print(); window.close();">
    <h1>[!GetField? &docid=`[*pageId*]` &field=`pagetitle`!]</h1>
    <div>[!GetField? &docid=`[*pageId*]` &field=`content`!]</div>
    </body>


    The GetField receives the "pageId" variable from the address and then gets the pate title, and content.

    This is the output of the popup window:



    As you can see, instead of the media statements appearing, the snippet call code is displayed.

    Is there a better way of doing this that I’m missing?

    For the record, I’m using MODx version 0.9.6.3

    Thanks!

    [UPDATE : see further down for "Contact Us" eform page issue]
      • 4172
      • 5,888 Posts
      thats because you call your content with the uncached call [!GetField? &docid=`[*pageId*]` &field=`content`!]

      did you try to call your snippet cached?

      nested snippetcalls have to be reversed uncached/cached

      [[media? &action=`summary` &numarticles=`5` ]]

      maybe you have also to set your document to uncached then ...................

      btw: instead of using href="[~[!GetField? &docid=`[*id*]` &field=`id`!]~]#" you can simply use href="[~[*id*]~]#"

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 21054
        • 78 Posts
        Thanks that helps greatly!

        I have most of it working now. Except for a specific page that isn’t quite working as expected. I’ll have more of a look into it and post it here if I can’t resolve it.