We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19370
    • 24 Posts
    Hi to all, I’m using a snippet to process an generated document. For that, i created a template with " [!snippetname?&content=`[*content*]`&title=`[*pagetitle*]`!] "
    when i wan’t to document be processed by that snippet, i change the template on the document.

    what does my snippet?
    well, my snippet uses tcpdf php class to convert html to pdf, i tested, it works, but the problem isn’t on snippet.

    what’s the problem?
    if the content place-holder outputs an ’=’ char or ’&’ char it breaks the flux, and the first letter behing and everything in front of the processed output goes out! example:
    "<img src=’sdgdsgsdgtdst.jpg’ />" it outputs "<img sr" to the snippet.



    can anybody help me?

    i’m using ModX 1,0,2 Evolution

    Thanks in Advance to All.
      • 19370
      • 24 Posts
      Hi all, i will reformulate the question with examples:



      Hey all

      i have a snippet call like this:

      [!mysnippet?&content=`[*content*]` !]


      What happen is that, if i send some html like this:

      [!mysnippet?&content=`<p color='red'>Yeah</p>` !]


      it will return this:

      <p colo


      the [test only] snippet code (mysnippet) is:

      <?php
      return $content;
      ?>


      Why is this happening? My actual snippet is converting html to pdf, so i really need this.

      Thank you all grin

      EDIT: I’m using Modx Evo 1.0.2
      on Stackoverflow

        • 3749
        • 24,544 Posts
        You can’t use "=" in a snippet tag except to assign parameters. The secret is to change it to something else (e.g. "EQUALS"), then use str_replace() in the snippet to change it back.
          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
          • 20413
          • 2,877 Posts
          You could use &docid=`[*id*]` in your snippet call

          Then in your snippet:
          <?php
          $output = $modx->db->getValue('SELECT `content` FROM `modx_site_content` WHERE `id` = '.$docid.'');
          return $output;
          ?>


          But if the snippet is just going to read current document use no params at all in snippet call!
          <?php
          $var1 = $modx->documentObject['content'];
          $var2 = $modx->documentObject['pagetitle'];
          
          $output = <<<END
          <h1>$var2</h1>
          <p>$var1</p>
          END;
          return $output;
          ?>


          http://svn.modxcms.com/docs/display/Evo1/Document+Object

          Interesting: http://stackoverflow.com/questions/tagged/modx
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 19370
            • 24 Posts
            Quote from: mrhaw at Apr 14, 2010, 11:31 PM

            You could use &docid=`[*id*]` in your snippet call

            Then in your snippet:
            <?php
            $output = $modx->db->getValue('SELECT `content` FROM `modx_site_content` WHERE `id` = '.$docid.'');
            return $output;
            ?>


            But if the snippet is just going to read current document use no params at all in snippet call!
            <?php
            $var1 = $modx->documentObject['content'];
            $var2 = $modx->documentObject['pagetitle'];
            
            $output = <<<END 
            <h1>$var1</h1>
            <p>$var2</p>
            END;
            return $output;
            ?>


            http://svn.modxcms.com/docs/display/Evo1/Document+Object

            Interesting: http://stackoverflow.com/questions/tagged/modx

            First of all, thanks for your repply! wink
            Well, i had already tried that, but we have here a little problem,
            and if the content has snippets? Using that way, it will show snippet call
            and not the result of the snippet call. :s

            I need this because i have a template called "ToPDF", and i have some pages
            that will be printed in pdf, so, this is the easer option.

            EDIT: the code of the template is some like this:
            [!topdf? &content=`[*content*]`!]
            


            Sorry for the english, i hope you understand it.
              • 19370
              • 24 Posts
              Quote from: BobRay at Apr 14, 2010, 10:50 PM

              You can’t use "=" in a snippet tag except to assign parameters. The secret is to change it to something else (e.g. "EQUALS"), then use str_replace() in the snippet to change it back.

              Thanks for your answer! wink

              Hm, so it seems to be an interessant bug on modx parsing.
              It is like ditto, i can’t use the "@CODE:" functionaloty.
                • 4172
                • 5,888 Posts
                why not call your snippet like this:
                [!topdf!]


                and in your snippet:

                $content=$modx->documentObject['content'];
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 20413
                  • 2,877 Posts
                  Parsed content? Try http://modxcms.com/forums/index.php/topic,46561.msg274314.html#msg274314

                  $output = $modx->parseDocumentSource($content);
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 19370
                    • 24 Posts
                    Quote from: mrhaw at Apr 15, 2010, 10:42 AM

                    Parsed content? Try http://modxcms.com/forums/index.php/topic,46561.msg274314.html#msg274314

                    $output = $modx->parseDocumentSource($content);


                    Thanks again for your reply! wink
                    To test, i have done this:

                    $content = $modx->parseDocumentSource($modx->documentObject['content']);
                    echo $content;
                    


                    And it prints the Ditto Call:

                    ...
                    <h3>Pacotes no Orçamento:</h3>
                    <p>
                    [!Ditto? &id=`orcamento` &parents=`73` &level=`1` &tpl=`md.orcamento.formvars` &noResults=` ` &orderBy=`menuindex ASC` !]
                    </p>
                    <p color="red">Yeah TEST</p>
                    ...
                    


                    huh

                    Thanks
                      • 19370
                      • 24 Posts
                      Quote from: Bruno17 at Apr 15, 2010, 09:56 AM

                      why not call your snippet like this:
                      [!topdf!]


                      and in your snippet:

                      $content=$modx->documentObject['content'];


                      Thanks for your answer Bruno wink

                      Well, it was like that, but when i found that "$modx->documentObject[’content’]" prints the snippet calls without "parsing"
                      i i’ve changed it.

                      My Last chance, is to hack modx using phx. sad
                      And i love modx because i don’t have to hack it. It would be frustating to me. sad


                      Sorry for my english. tongue