We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33372
    • 1,611 Posts
    I think that if your regular pages have templates something like:
    <DOCTYPE...>
    <html>
    ...blah blah blah...
    <div id="page">[*content*]</div>
    ...blah blah blah...
    </html>

    then that means that the content of that page is what you need to extract for your XML documents.

    So you could create corresponding XML documents that reuse the content from those pages with Ditto or a simple snippet that grabs that content and reformats it in an XML template with an XML content-type. Then you should just be able to use the MODx-generated URLs for those XML pages within your AJAX script.

    That way you don’t need to access the MODx database from outside it. MODx makes the XML documents and you put them together. Your AJAX page shouldn’t care where the XML came from as long as it’s got the right data in it.

    There are surely other ways to do this as well...
      "Things are not what they appear to be; nor are they otherwise." - Buddha

      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
      • 32443
      • 37 Posts
      Quote from: ZAP at Jan 17, 2007, 12:35 AM

      I think that if your regular pages have templates something like:
      <DOCTYPE...>
      <html>
      ...blah blah blah...
      <div id="page">[*content*]</div>
      ...blah blah blah...
      </html>

      then that means that the content of that page is what you need to extract for your XML documents.

      So you could create corresponding XML documents that reuse the content from those pages with Ditto or a simple snippet that grabs that content and reformats it in an XML template with an XML content-type. Then you should just be able to use the MODx-generated URLs for those XML pages within your AJAX script.

      That way you don’t need to access the MODx database from outside it. MODx makes the XML documents and you put them together. Your AJAX page shouldn’t care where the XML came from as long as it’s got the right data in it.

      There are surely other ways to do this as well...

      that was pretty much dead on now off to do it...

      im pretty sure i could figure out how to use the through the modx api to get to the content

      im thinking i would make the snippet and call it

      in the manager and then use that to serve it as text/xml

      right?

      but where would the call be to? index-ajax.php ?

        call it ModSeX o yeah smiley

        check us out and we need help Upscale Webservices http://www.upscalews.com/
        • 25663 MODX Staff
        • 12,272 Posts
        Ditto can output it without all the extra hassle of having to write a separate snippet. You’ll need a Ditto-specific template and the page that ditto is on will need a page template with the appropriate document type.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 32443
          • 37 Posts
          okay after much bashing my head on my desk I have working prototype smiley

          well... kinda see it gets the document and serves it as xml but i have no idea how to make it take a post parameter could some one help please

          pretty pretty please with suggars on top? its like one step from done


          
          <?php
          /*
           * Snippet Name: Get A Doc
           * Short Desc: returns content from another page on the site as xml
           * Author: Wiliam Harris
           * Version: 0.1
           * Last Edited: 30-Jan-2007
           * Function: returns content from another page on the site as xml
           *
           * ok people I hope its readily apparent that I don't know what im doing but im workiing on it :)
           *  all help and suggestions appercieated (including speelling)
           *
           */
          
          $wpage = $_POST['docid'] ;
          
          // set your default doc, there is probably a modx thing for this if anyone knows feel free to suggest
          $wpage = isset($wpage)? $wpage : 5;
          
          $doc = $modx->getDocument($wpage);
          
          $wantedContent = $doc['content'];
          
          $output =  '<?xml version="1.0" encoding="'.$modx->config['etomite_charset'].'" ?>'."\n".
                          $wantedContent ;
          
          return $output;
          ?>
          
          



          and i suppose a little explanation is in order as well

          red = what its supposed to do

          green = what is does now already

          it takes a post parameter that is simply the your desired document id if you don’t set one it automatically sets it to the 5th one ,(my default just change to set yours), then it returns the content area of that document id in a an xml format

          and thats it smiley

          ******** update *****************

          it works im silly smiley

          with get and post d-(^_^)

          now im trying to change it to take page names instead of doc ids so its easier on me

          help again appreiciated

          as always let me know if you are interested

          use it if you like d-(^_^)-b

          that would make me happy

          and if you think its useful or it sucks or it could be better I would love to here from you
            call it ModSeX o yeah smiley

            check us out and we need help Upscale Webservices http://www.upscalews.com/
            • 27376
            • 576 Posts
            Could you provide a live example of your solution? I’m not sure I understand what you’re doing. AJAX uses javascript and is not Search Engine Optimized since Search engines don’t parse links that use JS. It seems to me your solution hinders SEO.
              • 32443
              • 37 Posts
              Quote from: williscool at Feb 12, 2007, 05:23 PM

              Quote from: sirlancelot at Feb 12, 2007, 11:49 AM

              Could you provide a live example of your solution? I’m not sure I understand what you’re doing. AJAX uses javascript and is not Search Engine Optimized since Search engines don’t parse links that use JS. It seems to me your solution hinders SEO.

              sure here it is working

              http://www.hustlemanent.com/

              the point of the snippet works like this:

              i have like 7 seven pages that all use the same template

              the only difference is the content of one div with the id of "page"

              this way all of the code that will ever be in any of the pages exists statically (not simplely as xml for an ajax request)

              the content (xml) that is placed in the "page" div is in a modx document

              now originally I wanted a function that could take a whole html page and crawl it with the dom to get the xml in the id page

              this was because I was very new to both php and modx at the time and didn’t know that

              a) php4 has *cough*piss*cough* poor xml support and

              b) modx has a much simpler, faster, and easier solution

              so what my snippet does instead is return the content of a modx document by its modx id formated as xml

              i use a request variable "doc" to chose which ever document I want

              if a visual would help your understanding better check out my xml generator here:

              http://www.hustlemanent.com/xml

              then try http://www.hustlemanent.com/xml?doc=18

              you can also change it to 5,7,8, 9 and a few others

              as you can see it works with gets but the actual script uses posts

              give it a shot smiley

              and because the documents are all centered around the same template using the content of the "page" id/corresponding modx document from one in another doesn’t cause any problems

              I also don’t use any inline javascript or javascript in the links. so if javascript is off the page works as if it was never there
                call it ModSeX o yeah smiley

                check us out and we need help Upscale Webservices http://www.upscalews.com/
                • 32443
                • 37 Posts
                so my question to you sirlancealot , nice nick by the way wink , is will that still screw with my neophyte attempt at helping my site’s SEO?
                  call it ModSeX o yeah smiley

                  check us out and we need help Upscale Webservices http://www.upscalews.com/
                  • 27376
                  • 576 Posts
                  What browser are you designing your page for? I tried it in Firefox 2.0.1, IE 6, and Safari 2.0.4 and couldn’t get to any page other than the home page "Welcome to Hustle Man Entertainment." Each link I clicked on the left side menu made the content move off the screen and then it came back, unaltered.

                  I’d recommend that if you want a site that is as flashy as you’re trying to achieve, you should move it to flash, the DOM is not really standardized yet in all browsers.

                  I’m not a JScripter though, so maybe someone with expertise in Javascript could help you more...