We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11121
    • 79 Posts
    I am using Formit to post and edit resource from frontend.

    When editing rsource, path of the page is like this "http://xxxxxx.xx/index.php?id=245&resId=481".

    I need to use the resId number inside my formit call. How can I retrieve it?
    • Use a small snippet to get the $_GET['resid'] value. Make sure to sanitize it in the snippet so that malicious visitors don't try to hack your site through it.

      Even better, try BobRay's NewsPublisher extra, or modx.pro's Tickets, which both are excellent packages for handling front-end creation and editing.

      If linking to the Manager will suit your needs, check out QuickBar. It puts a slide-down menu at the top of the page with links to edit the resource in the Manager or create a new resource with the same parent.
        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
        • 42562
        • 1,145 Posts
        Here is an already-made snippet, http://modx.com/extras/package/geturlparam.
        Place the snippet call in Formit, exactly where you need to output the value of the parameter.

        NewsPublisher is a complete and fantastic barebone solution for you.
        And of course, you can try TinymceWrapper's snippet, TinyMagicPublisher for more awesomeness
          TinymceWrapper: Complete back/frontend content solution.
          Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
          5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
          • 11121
          • 79 Posts
          Quote from: donshakespeare at Feb 06, 2016, 03:43 AM
          Here is an already-made snippet, http://modx.com/extras/package/geturlparam.
          Place the snippet call in Formit, exactly where you need to output the value of the parameter.

          NewsPublisher is a complete and fantastic barebone solution for you.
          And of course, you can try TinymceWrapper's snippet, TinyMagicPublisher for more awesomeness


          geturlparam works. But I have a problem. I added a placeholder ([[+article]]) and I'm trying to put this placeholder inside a getResourcefild call but is returns empty. Placeholder works outside snippet.

          [[!getUrlParam? &name=`resId` &int=`1`]]
          [[+article]]  
          
          [[!FormIt? 
              &preHooks=`resource2formit, Formit2AjaxUpload`
              &resource2formitfields=`template,resource_id,Active,pagetitle,Paratiriseis,Sex,Race,Age,Weight,Pedigree,Microchip,Passport,Area,Phone,Email,content,refnum,IMAGE`
              &hooks=`AjaxUpload2Formit, formit2resource, redirect` 
              &resId=`[[~[[*id]]]]`
              &redirectTo=`106`
              &ajaxuploadFieldname=`IMAGE`
              &ajaxuploadTarget=`images/uploads/`
              &ajaxuploadUid=`image_[[!getResourceField? &id=`[[+article]]` &field=`refnum` &processTV=`1`]]` 
              &validate=`
          
          
          [ed. note: gordonas last edited this post 8 years, 1 month ago.]
            • 3749
            • 24,544 Posts
            Try adding this to your getResourceField call:

            &isTV=`1`


            BTW, this will only work if Article is a TV and contains the text you need for your image uid.
              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
              • 11121
              • 79 Posts
              First of all, my mistake, placeholder doesn't work. Problem remains the same though. What I mean:

              [[!getUrlParam? &name=`resId` &int=`1`]]
              [[!getResourceField? &id=`[[!getUrlParam? &name=`resId` &int=`1`]]` &field=`refnum` &processTV=`1` &isTV=`1`]]
              <div id="row_edit">
              <span class="font_cond_24"><strong>Επεξεργασία αγγελίας</strong></span>
              <br><br>
              [[!FormIt? 
                  &preHooks=`resource2formit, Formit2AjaxUpload`
                  &resource2formitfields=`template,resource_id,Active,pagetitle,Paratiriseis,Sex,Race,Age,Weight,Pedigree,Microchip,Passport,Area,Phone,Email,content,refnum,IMAGE`
                  &hooks=`AjaxUpload2Formit, formit2resource, redirect` 
                  &resId=`[[~[[*id]]]]`
                  &redirectTo=`106`
                  &ajaxuploadFieldname=`IMAGE`
                  &ajaxuploadTarget=`images/uploads/`
                  &ajaxuploadUid=`image_[[!getResourceField? &id=`[[!getUrlParam? &name=`resId` &int=`1`]]` &field=`refnum` &processTV=`1`]]`



              getUrlParam and getResourceField calls, both are working outside FormIt and they give results as expected.

              Inside Formit, getUrlParam doesn't work.

              I tested getResourceField inside FormIt with article number at &id and works fine.

              So getResourceField inside Formit works. But getUrlParm inside getResourceField, inside Formit, doesn't work...:)


              P.S. Strangely at getResourceField when I put article number at &id worked only without isTV=`1`. [ed. note: gordonas last edited this post 8 years, 1 month ago.]
                • 11121
                • 79 Posts
                UPDATE!!!

                    &ajaxuploadUid=`image_[[!getResourceField? &id=`[[getUrlParam? &name=`resId` &int=`1`]]` &field=`refnum` &processTV=`1`]]`
                



                When I call getUrlParam cached inside FormIt works!
                  • 4172
                  • 5,888 Posts
                  But I think, this will cache the result of the getUrlParam - snippet and return the same value each time, once it is cached.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 11121
                    • 79 Posts
                    Quote from: Bruno17 at Feb 07, 2016, 06:51 AM
                    But I think, this will cache the result of the getUrlParam - snippet and return the same value each time, once it is cached.

                    For some unknown reason this is not happening! Keep checking though. [ed. note: gordonas last edited this post 8 years, 1 month ago.]