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

    I have created Shop in MODx and I have container Shop in which are all products in the Shop. Rendering of the products is provided by the Ditto 2.0.2 snippet.

    So, when user click on the heading of the product, details of the product are showed up and on the end of this document should be the price and the link which add product to the basket, I have created the chunk in which is this code.

    And here the problem is, my client must adding this chunk manually for every document(which is in this case product detail) and it’s very uncomfortable, I want to do this somehow differently(otherwise).

    How can I add this chunk on-the-fly to the end of currently rendered document ? (when the document is rendered)

    Can you suggest me some solution ? Programming some snippet isn’t any problem for me, for this shop I have programmed 10 snippets and a lot of classes, but I don’t know how can I solve this.

    Thank you for any suggestion.
      • 7231
      • 4,205 Posts
      You might be able to auto-insert a chunk by using a plug-in set to onWebPagePrerender. You could have it only add this to documents under a specific parent (shop).

      Or just add it to the template in a snippet with a logic to only show if parent is the id for shop. The snippet would be much easier for me personally (I do this all of the time) but a plug-in might be more elegant wink
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 27843
        • 170 Posts
        Quote from: dev_cw at Dec 23, 2008, 12:47 PM

        You might be able to auto-insert a chunk by using a plug-in set to onWebPagePrerender. You could have it only add this to documents under a specific parent (shop).

        Or just add it to the template in a snippet with a logic to only show if parent is the id for shop. The snippet would be much easier for me personally (I do this all of the time) but a plug-in might be more elegant wink

        Hi,

        thank you very much, both cases are usable, I choice plugin, the code will be very simple and it’s cleaner.

        Once again thank you very much wink
          • 7231
          • 4,205 Posts
          If possible please share your code once you get it working. I like using custom plug-ins and need more experience, and I learn better by example. grin
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 27843
            • 170 Posts
            Quote from: dev_cw at Dec 23, 2008, 02:27 PM

            If possible please share your code once you get it working. I like using custom plug-ins and need more experience, and I learn better by example. grin

            ok, if I do this I post code here, but xmas are here, so i will work next week, normaly it would be immediately, but I have holiday now wink
              • 27843
              • 170 Posts
              Quote from: dev_cw at Dec 23, 2008, 02:27 PM

              If possible please share your code once you get it working. I like using custom plug-ins and need more experience, and I learn better by example. grin

              So I have done my plugin, but I discover, that event onWebPagePrerender isn’t idealy. I have used event OnParseDocument which is much better, I inspired from this site http://wiki.modxcms.com/index.php/Order_of_execution which is super wink

              The code is very very simple:
              <br />        if ($this->_modx->documentObject[’parent’] == 23) {<br />            $this->_modx->documentObject[’content’] .= $this->_modx->getChunk(’basketPrice’);<br />


              I hope that this help you
                • 36416
                • 589 Posts
                Quote from: snop at Jan 07, 2009, 01:58 AM

                I hope that this help you

                Is this really better/more flexible than (a bit of PHx magic)
                 [+parent:is=`23`:then=`{{basketPrice}}`+] 

                in the template?
                  • 27843
                  • 170 Posts
                  Quote from: Eol at Jan 07, 2009, 02:18 AM

                  Is this really better/more flexible than (a bit of PHx magic)
                   [+parent:is=`23`:then=`{{basketPrice}}`+] 

                  in the template?

                  fuu, this looks great, i must look at PHx, it’s more comfortable how my plugin wink