We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    I have happily used GetField 1.2.1 and can reports it works with PHP 5.1.6 and 0.9.5 alright smiley

    So far I have used it only as a single call.
    But now I need to have multiple calls on the same page and I get a nice blank page... I tried both cached and uncached, also uncached the page altogether but same blank page result :’(

    I am running 0.9.5 rev 1732, maybe it has to do with that too...

    Input ?
      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 36541
      • 222 Posts
      Sorry, davidm, I can’t test the snippet with PHP 5.1.6 sad

      However I successfully used it with multiple calls in MODx 0.9.5 build 1776 (also 1732 AFAIR).

      I used a following call based on the sample site:

      <h3>[[getField? &docid=`9` &field=`pagetitle`]]</h3>
      
      <p>[[getField? &docid=`9` &field=`content`]]</p>
      
      <h3>[[getField? &docid=`18` &field=`pagetitle`]]</h3>
      
      <p>[[getField? &docid=`18` &field=`content`]]</p>
      
      <h3>[[getField? &docid=`7` &field=`pagetitle`]]</h3>
      
      <p>[[getField? &docid=`7` &field=`content`]]</p>
        This is the web: the only thing you know about who will come is that you don't know who will come.
        • 6726
        • 7,075 Posts
        Hi grad,

        Sorry for not reporting this earlier, but Heliotrope has provided me with a solution to this :
        http://modxcms.com/forums/index.php/topic,8092.msg57532.html#msg57532

        Paul gave me an explanation as to why the original GetField didn’t work for me :

        Quote from: PaulGregory at Oct 20, 2006, 08:43 AM

        Well done heliotrope.

        Hmmn, seems I was still on 1.1 (you’re on 1.2.1). There’s clearly more activity on this snippet than I thought!

        Intriguingly, [!GetField!] [!GetField!] worked happily for me on my test box - presumably my setup allows functions to be redeclared. This also means I can’t test the above fixes easily (because I don’t have the problem in the first place!). I’ll have to watch out for that!

        How do I modify my php setup to allow functions to be redeclared ?
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l&#39;outil id
          • 10487 MODX Staff
          • 1,535 Posts
          How do I modify my php setup to allow functions to be redeclared ?
          I don’t think you can allow PHP to redeclare functions - unless you’re dealing class methods and inheritance which is a whole different ball game.

          I believe in Paul’s example, calling the snippet twice (with the same call/parameters) means that the snippet is only processed once. Using different parameters in the snippet call would mean that the snippet code is executed more than once and at that point, it’ll throw the ’Cannot redeclare function ...’ error.

            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 6726
            • 7,075 Posts
            Thanks Garry for the input, makes it clearer. Seems Heliotrope has nailed whatever broke it for multiple calls anyway smiley
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l&#39;outil id
              • 36541
              • 222 Posts
              It seems that my setup does allow functions to be redeclared thus I couldn’t reproduce the error. getField was intended to be used in multiple calls - that was my original need as I had to make a listing of sub-documents a part of which were not shown in the menu.

              Anyway, I’ll take a look at it and update the snippet code in few days, I hope (as I am rather busy at the moment). I didn’t realize my little snippet is of such a wide usage. That’s nice it turned helpful for someone smiley

              Also, I didn’t know there is a wiki for MODx! Have to take a look at it.
                This is the web: the only thing you know about who will come is that you don't know who will come.
                • 36541
                • 222 Posts
                I updated repository with version 1.2.2 which has a quick fix to "Cannot redeclare function..." error.

                In the next few days I plan to rework the code to meet coding guidelines from MODx wiki.
                  This is the web: the only thing you know about who will come is that you don't know who will come.
                  • 6726
                  • 7,075 Posts
                  Thanks a lot grad, at least the error message will help those who have a limiting config like me...
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 36541
                    • 222 Posts
                    Ladies and Gentelmen wink

                    I would like to present a brand new version of GetField. The changes to the code are significant, however nothing changes in the way it works. You don’t have to change the calls you already made. smiley

                    I applied coding guidelines from MODx Wiki and made the package compatible with MODx Resource Wizard. Therefore I kindly ask you to test this beta and report how it behaves before I post it in the repository.

                    I hope you will like it smiley
                      This is the web: the only thing you know about who will come is that you don't know who will come.
                      • 6726
                      • 7,075 Posts
                      Great work, making it unnecessary to change the call, sticking to dev procedure and making it compatible with the Resource Wizard : cool cool

                      Thanks !
                      I’ll update and report smiley
                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l&#39;outil id