We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15413
    • 26 Posts
    Sorry - this is not exactly MODx-related, but in this case it would be perfect for a MODx-project I´m working on at the moment smiley

    Is it possible to dynamically get the contents of a site http://www.spreadshirt.net/shop.php?sid=72211 and to integrate them into another site? In this case I want to integrate a free online shop seamlessly into my layout. Nothing illegal, no foregin site content. All for the User experience smiley

    Would be great if someone could help smiley

    Greetings,
    Karsten
      My last Modx-Try: http://dhbblog.zendezentrale.com
      My very personal Modx-Playground: http://www.pornocops.com
      (under construction at any time wink )
      • 32241
      • 1,495 Posts
      Sure thing karsten, use this function, taken from php.net
      	// Parser function to parse document page into html string
      	function parseWebPage($url) {
      		$ch = curl_init();
      		curl_setopt($ch, CURLOPT_URL, $url);
      		curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
      		$store = curl_exec ($ch);
      		$xml = curl_exec ($ch);
      		curl_close ($ch);
      		return $xml;
      	}
      


      It will return all the html code for the specific page. After that, you can strip out the body part only with explode() function twice for easy to use, the first one to explode against opening body tag and keep the part for body, and the last one will be against the closing tag with hal body content without the header section.
      For example:
      $temp = explode('<body>', $xml);
      $xml = $temp[1];
      $temp = explode('</body', $xml);
      $xml = $temp[0];
      echo $xml;
      


      One thing to note though, all the link is relative, so you need to use str_replace or preg_match to find all the relative link and append the absolute url to the link. Basically this will give you the idea on how to do it, but it will be hard to maintain a consistent look of the site without an iframe or frame.
        Wendy Novianto
        [font=Verdana]PT DJAMOER Technology Media
        [font=Verdana]Xituz Media
        • 21595
        • 159 Posts
          • 15413
          • 26 Posts
          Quote from: Djamoer at Feb 14, 2006, 09:13 PM

          Sure thing karsten, use this function, taken from php.net

          Dear Djamoer and Nissai!

          Thanks a lot once again to you and the great modx-community smiley
          I´ll try it out tomorrow smiley

          Best regards,
          Karsten
            My last Modx-Try: http://dhbblog.zendezentrale.com
            My very personal Modx-Playground: http://www.pornocops.com
            (under construction at any time wink )
          • Quote from: nissai at Feb 14, 2006, 10:49 PM

            http://etomite.org/browsesnippets.html?int_snipid=177&lst_category=6

            Etomite doesn’t allow external linking to their repository. Although how one is then supposed to refer to one of their snippets is a good question.
              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
              • 7455
              • 2,204 Posts
              Quote from: sottwell at Feb 15, 2006, 06:27 AM

              Quote from: nissai at Feb 14, 2006, 10:49 PM

              http://etomite.org/browsesnippets.html?int_snipid=177&lst_category=6

              Etomite doesn’t allow external linking to their repository. Although how one is then supposed to refer to one of their snippets is a good question.

              Just copy past the url I think that works fine
                follow me on twitter: @dimmy01
              • Somone care to port that snippet?
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                  • 32241
                  • 1,495 Posts
                  Here is a quick cleanup of the code, which I basically didn’t do anything with the code at all. grin

                  // Snippet Parameters &phpfile
                  if (!isset($phpfile) || $phpfile == "")
                    return "No file specified.";
                  
                  ob_start();//Start the buffer
                  include $phpfile; //include the file and run it
                  $ob_contents = ob_get_contents();//get contents from the buffer
                  ob_end_clean();//and kill/delete the buffer
                  return $ob_contents;//return it to etomite.
                  
                    Wendy Novianto
                    [font=Verdana]PT DJAMOER Technology Media
                    [font=Verdana]Xituz Media