We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7659
    • 2 Posts
    Hi,

    I am working on a site that has a number of feature boxes that appear in the right column. I want to allow users to select what features should be displayed on each page so I have a snippet called displayFeatures that is called from the template and displays the correct feature boxes for the current page.

    Each feature box is set up as a document in the CMS so the users can update the content of them. One of the boxes is quick enquiry form and calls the eForm snippet. On the screen though I can see the snippet call rather than the snippet output. I think this is because I am calling it from another snippet but I’m not sure how I can get around this?

    Thanks in advance for your help
    Denise smiley
      • 22840
      • 1,572 Posts
      If I understand this correct you have a snippet that is calling a snippet inside it huh?

      If so in you page or template call the snippet as you normaly would but for the snippet call inside the snippet try [+snippet name+]
        • 26931
        • 2,314 Posts
        i think you should try to call the snippet inside of another snippet cached [[ snippetname ]], and the other one uncached [! snippetname2 !]
          • 22840
          • 1,572 Posts
          Quote from: sharkbait at Nov 25, 2009, 04:08 PM

          i think you should try to call the snippet inside of another snippet cached [[ snippetname ]], and the other one uncached [! snippetname2 !]

          Reading that back yeh you may be right, I was thinking of TV’s inside chunks ( I think ) lol
            • 3749
            • 24,544 Posts
            Denise, when you say you are calling a snippet from within a snippet, do you mean that the second snippet is in a snippet parameter of the first snippet’s tag or are you using $modx->runsnippet() from within the first snippet to execute the second snippet?

            Or are you maybe using some other method that perhaps doesn’t work?
              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
              • 7659
              • 2 Posts
              Hi,

              thanks everyone for the feedback - will try some of your suggestions tonight but thought I would post some more detail.

              I have a document that calls the eform snippet - [!eForm? &formid=`quick_enquiry` &to=`[email protected]` &tpl=`eFormQuickEnquiry` &report=`eFormReportQuickEnquiry` &thankyou=`eFormQuickEnquiry` &subject=`Quick Enquiry`!]

              I then have a snippet that is called from a template - [[displayFeatures]] - this is used to control what appears in the right column on each page and the document above is one of the possibilities. Here is the code for the displayFeatures snippet: -

              <?php
              $pageId = $document[’id’];
              $tvrFeatures = $modx->getTemplateVar("1", "*", $pageId, 1);
              $featureIdStr = $tvrFeatures[’value’];
              $featureIdArray = explode("||", $featureIdStr);
              $output = "";
              foreach ($featureIdArray as $id) {
              $featureDocument = $modx->getDocument($id);
              $output .= "<div id=\"ad\">" . $featureDocument[’content’] . "</div>";
              }

              echo $output;
              ?>

              So the call to the eform snippet is within the $featureDocument[’content’] called above it is not being executed.

              Thanks
              Denise

                • 4041
                • 788 Posts
                I ran into a very similar situation recently, try this amended snippet and see if it helps:

                <?php
                // displayFeatures snippet
                
                   $pageId = $document['id'];
                   $tvrFeatures = $modx->getTemplateVar("1", "*", $pageId, 1);
                   $featureIdStr = $tvrFeatures['value'];
                   $featureIdArray = explode("||", $featureIdStr);   
                   $output = "";
                   foreach ($featureIdArray as $id) {      
                      $featureDocument = $modx->getDocument($id);
                      $parsed_content = $modx->parseDocumentSource($featureDocument['content']);
                      $output .= "<div id=\"ad\">" . $parsed_content . "</div>";
                   }
                   
                   echo $output;
                ?>
                  xforum
                  http://frsbuilders.net (under construction) forum for evolution