We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24075
    • 83 Posts
    Thanks
    in Firefox is OK
    in Avant Browser No !? (but in MSIE 8 is too OK)
    :-)
    Thank you!
      Petr Püschel, Czech Republic
      <hr>
      http://puschpull.org
      <hr>
      • 16545
      • 358 Posts
      What about Getfield and Ajax script compatibility?

        • 30176
        • 99 Posts
        I am using GetField in a Jquery Tab. If the resource is published everything works fine. If the resource is unpublished the GetField snippet does not return a value. Is there anyway to get a value from an unpublished resource/document using Getfield?

        <div id="tabs">
        	
        <ul>
        <li><a href="#tabs-1">[[GetField? &docid=`67` &field=`pagetitle` ]]</a></li>
        <li><a href="#tabs-2">Proin dolor</a></li>
        <li><a href="#tabs-3">Aenean lacinia</a></li>
        <li><a href="#tabs-4">Contact Information</a></li>
        </ul>
        <div id="tabs-1">
        <p> [!DynContent?docid=`67`!]</p>
        </div>


        In the above code DynContent snippet works for both the published and unpublished state of the document. GetField is working only for the document while is is published.

        Thank you for any help on this.
          "Remember what Bilbo used to say: It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to."
          -J.R.R. Tolkien from The Lord of the Rings
          • 7455
          • 2,204 Posts
          Quote from: tmcleroy at May 19, 2010, 12:14 PM

          I am using GetField in a Jquery Tab. If the resource is published everything works fine. If the resource is unpublished the GetField snippet does not return a value. Is there anyway to get a value from an unpublished resource/document using Getfield?

          <div id="tabs">
          	
          <ul>
          <li><a href="#tabs-1">[[GetField? &docid=`67` &field=`pagetitle` ]]</a></li>
          <li><a href="#tabs-2">Proin dolor</a></li>
          <li><a href="#tabs-3">Aenean lacinia</a></li>
          <li><a href="#tabs-4">Contact Information</a></li>
          </ul>
          <div id="tabs-1">
          <p> [!DynContent?docid=`67`!]</p>
          </div>


          In the above code DynContent snippet works for both the published and unpublished state of the document. GetField is working only for the document while is is published.

          Thank you for any help on this.


          there is no option in getfield to do upubed, but you could add this by altering this line:

          while (($gfArrParent = $modx->getDocument($gfIntDocId,’parent’)) && ($gfArrParent[’parent’] != 0)
          to:

          while (($gfArrParent = $modx->getDocument($gfIntDocId,’parent’,0)) && ($gfArrParent[’parent’] != 0) || ($gfArrParent = $modx->getDocument($gfIntDocId,’parent’,1)) && ($gfArrParent[’parent’] != 0))
          )

          I did not test it but the case is that $modx->getDocument has the option to get unpubed or published docs

          maybe you also need to to similar edit to the $modx->getTemplateVarOutput part if you need to use tv’s that are in docs that are unpublished
          the 3th option is the pubbed (1) or unpubed (0) option
            follow me on twitter: @dimmy01
            • 30176
            • 99 Posts
            Thanks Dimitri! I appreciate your passing this along. I am looking into this now.
              "Remember what Bilbo used to say: It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to."
              -J.R.R. Tolkien from The Lord of the Rings
              • 10913
              • 66 Posts
              I needed to get the returned value inside a tag put if the value didn’t exist the tag pair shouldn’t print. So I made some tweaking. Didn’t read the whole thread so I don’t know if someone already did this.

              I added $tpl to getField so now I can print stuff the way I want. To work with this you have to add &tpl=`<tag>[+gf.value+]</tag>` to your call.

              Here’s the modded files

              -Tommi
                The sun always shines for tough guys.
                • 33968
                • 863 Posts
                I’m simply trying to retrieve the longtitle field from a document’s parent on the 2nd document tree level, ie. a container sitting in the root.

                [[GetField? &parent=`1` &topid=`1` &field=`longtitle`]]


                This returns nothing. If I change &topid to ’0’ it returns the longtitle from the home page document.
                Confused!! Any ideas?
                  • 36926
                  • 701 Posts
                  Quote from: lucas at Jul 12, 2010, 10:48 AM

                  I’m simply trying to retrieve the longtitle field from a document’s parent on the 2nd document tree level, ie. a container sitting in the root.

                  [[GetField? &parent=`1` &topid=`1` &field=`longtitle`]]


                  This returns nothing. If I change &topid to ’0’ it returns the longtitle from the home page document.
                  Confused!! Any ideas?

                  Was having similar issues for pagetitle. Managed to get this to work.

                  [[GetField? &parent=`1` &parentLevel=`1` &field=`pagetitle`]]
                  
                    • 33968
                    • 863 Posts
                    Aha, that worked for my child documents, ended up using:
                    [[GetField? &parent=`2` &parentLevel=`1` &field=`longtitle`]]

                    Thanks bennyb.

                    But I have a ’featured’ box on the home page that displays content pulled from the same documents via a ditto call. I can’t get that to work using the same GetField call in the Ditto template. Any ideas?
                      • 36926
                      • 701 Posts
                      Quote from: lucas at Jul 14, 2010, 04:38 AM

                      Aha, that worked for my child documents, ended up using:
                      [[GetField? &parent=`2` &parentLevel=`1` &field=`longtitle`]]

                      Thanks bennyb.

                      But I have a ’featured’ box on the home page that displays content pulled from the same documents via a ditto call. I can’t get that to work using the same GetField call in the Ditto template. Any ideas?

                      Hey lucas,

                      Not 100% exactly what you are trying to do.

                      When you say same documents, do you mean it’s pulling in content from same set of documents each time. If so can you use the &docid=`7` 7 being the id of the document you want the content from.

                      Or are you saying you want to pull in the same content as what the GetField call is pulling in but within the featured box thing.