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

    I have created a module and have most of the snippet logic in place

    I wanted to make use of a chunk and am still not clear how to

    e.g.

    <div>[+productName+]</div>
    <div>[+price+]</div>

    how do I make my snippet insert the appropriate values into those place holders?
    the snippet has generated the values. what do I do? or what code do I write in the chunk?
    where do I place it?

    sorry am still new

    but loving it!!! wink
      • 4971
      • 964 Posts
      I think you have to use the function:

      $modx->setPlaceholder(’productName’, ’Television’);
      $modx->setPlaceholder(’price’, ’600.00’);

      and then you can use the placeholders anywhere you want...
        Website: www.mercologia.com
        MODX Revo Tutorials:  www.modxperience.com

        MODX Professional Partner
        • 16183
        • 1,390 Posts
        If I understand you correctly, I think you need to use modx’s templating abilities, e.g. using setPlaceholder API function

        There’s no need for me to re-invent the wheel here since this is already well documented in the wiki...so, here you go, a link to get you there  ;D

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

        Hope it’s what you wanted

        /k

        edit: Charliez beat my by a minute there wink
          • 7155
          • 160 Posts
          Thanks guys.

          So I create the chunk through the manager under resources, then all I will have to do is use the setPlaceholder function in the modx API...

          If I’m wrong, please correct me, otherwise, thanks for the help!
            • 16183
            • 1,390 Posts
            No, logic (php) cannot be placed in chunks. Put the placeholders in you chunk

            Have a look at this tutorial on creating modules in modx: http://modxcms.com/creating-a-module.html Note that this one runs over several pages, so click arrows at bottom to advance [can be missed, so thought to mention it wink]

            OR this one by Susan

            http://www.sottwell.com/create-module.html

            Hope it answers your question, if not, please clarify
              • 7155
              • 160 Posts
              Quote from: kongondo at Sep 25, 2008, 04:41 AM

              No, logic (php) cannot be placed in chunks. Put the placeholders in you chunk

              Have a look at this tutorial on creating modules in modx: http://modxcms.com/creating-a-module.html Note that this one runs over several pages, so click arrows at bottom to advance [can be missed, so thought to mention it wink]

              OR this one by Susan

              http://www.sottwell.com/create-module.html

              Hope it answers your question, if not, please clarify

              i appreciate your effort

              i meant create chunks through the resource manager, then make use of the modx API in the snippet.

              I am well aware that chunks are not meant for logic wink and have also completed the module... It was making use of chunk placeholders and placing the values from snippets that kinda got me confused.

              thanks again!
                • 16183
                • 1,390 Posts
                Nice one! grin

                Glad you got it working. Is it working without problems?
                  • 7155
                  • 160 Posts
                  the module is working well, on the backend. thanks to all those modules for download, thanks to forum people like susan...and you and others... snippet almost done, now that the chunks, placeholder thing is clear