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

    Quite new to modx so unsure if this is possible or best way to approach this.

    I have setup a poll snippet which I have successfully included in a template:
         [!pollvote? &pollid=`1`  &onevote=true &ovmessage=`You can only vote once` &resultsbutton=true!]


    However as I want to make this reusable and be able to slot in and out of various pages I have attempted to create a chunk running this snippet. However it just prints out the code.
    <div class="poll">
                	<h2>Reader's poll</h2>
                     [!pollvote? &pollid=`1`  &onevote=true &ovmessage=`You can only vote once` &resultsbutton=true!]
                </div>


    How can I achieve this, is this the correct approach?

    All comments welcome!
      • 26016
      • 561 Posts
      That’s a very logical idea, and I’m certain that I’ve tried it myself before. As I recall, a chunk can only be HTML, and will not work with any snippet calls.

      I can’t think of an obvious answer... let’s see... you could set up a TV, have the input be radio buttons (or dropdown options), and have the default be "nothing", and the other selection be your call. Might be worth a try. Now that I think about it, I don’t know if you can have a snippet call there, either, but it might work.

      Cheers, Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 5340
        • 1,624 Posts
        It;s wierd that it doesn’t work

        I always use chunks that have snippets in them

        e.g.

        <div class="spaceTop1Lines"></div>
        [!Wayfinder? &startId=`2` &includeDocs=`3,4,5,18` &outerTpl=`LeftMenuOuterTpl` &rowTpl=`LeftMenuRowTpl` &hereClass=`selected`!]
        


        And also according to the documentation the order of execution is:

        1. [*content*] -- Template variables (built-in and custom)
        2. [(site_name)] -- Settings tags
        3. {{chunk}} -- Chunk tags
        4. [[Cached_Snippets]]
        5. [+placeholders+]
        6. [!Uncached Snippets!]
        7. [~11~] -- Link tags
        8. [^t^] -- Timing tags

        So AFAIK it should work. Is it possible that you are doing something else?
          • 5340
          • 1,624 Posts
          shouldn’t all parameters in your snippet call be like =`true` instead of just true
            • 26016
            • 561 Posts
            I haven’t tried snippet calls in a chunk in ages, it just hasn’t come up, so I’m thinking that Cipa is probably right! Maybe it will work fine, but you just have some typos.
              MODx and Wordpress development
              Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
              • 1169
              • 312 Posts
              Snippets from chunks works for me.

              I am calling WebloginPE from a chunk.

              The rule as I understand is no PHP in chunks but PHP in snippets.
                DEVELOPMENT ENV:- Ubuntu 12.04 | MODx Revolution 2.2.8 | LAMP 2i Apache 2.2.22 | Php 5.3.10 | Mysql 5.5.31 MySQL client version: 5.5.31
                • 11699
                • 11 Posts
                simply changed [! snippet code !] to [[snippet code]] and it worked!

                Thanks for all your help.
                  • 3749
                  • 24,544 Posts
                  Quote from: cipa at Mar 05, 2010, 11:13 AM


                  And also according to the documentation the order of execution is:

                  1. [*content*] -- Template variables (built-in and custom)
                  2. [(site_name)] -- Settings tags
                  3. {{chunk}} -- Chunk tags
                  4. [[Cached_Snippets]]
                  5. [+placeholders+]
                  6. [!Uncached Snippets!]
                  7. [~11~] -- Link tags
                  8. [^t^] -- Timing tags

                  Cipa, Can you tell me where you found that?
                    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
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    All MODx tags can be used in chunks. I frequently put snippets with complex parameter lists in chunks so that TinyMCE (or a carelessly editing client) won’t mess with them. Much easier to fix a damaged chunk tag than a snippet call!
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 5340
                      • 1,624 Posts
                      Quote from: BobRay at Mar 08, 2010, 08:47 PM

                      Cipa, Can you tell me where you found that?

                      http://wiki.modxcms.com/index.php/Order_of_execution

                      Path:
                      http://wiki.modxcms.com/index.php/Main_Page -> API pages -> Order of execution