We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40763
    • 7 Posts
    So I had this posted under the add-on sections and I didn't get any replies in a month, so I hope do mind the repost here. Launching first site next week.

    I am just getting started with Modx and I would like to have an external link in my website use my local template and have a local URL address.I am using Revo 2.2.4. and I have setup the external link as a resource with the Resource Type of Weblink and a Content Type of text. It currently returns the page with an external URL. I just need it to fit into the current template, in Joomla this is setting up a menu item as a wrapper. Im pretty sure my fruitless web searches are just a matter of different terminology and I just need to add a snippet or add-on. Any help would be appreciated.

    Thanks Jonathan
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      So what you want to do is load the content of this external page into a MODx page? Or embed the external page?
        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
        • 40763
        • 7 Posts
        Scottwell-

        The external link is cold fusion script (listing a department directory) without a template, so to speak, around it so I just want to place the returned page into my site. So I guess I would like to load the external page into my template. The Joomla menu wrapper is the best example I have. Maybe it's a CMS linguistic translation problem.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, that would best be done either by AJAX or using an iframe.
            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
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            You may just be looking for a quick PHP snippet like this:

            if (!isset($url) || !empty($url)) { return 'No &url parameter passed.'; }
            $content = file_get_contents($url);
            return $content;


            which you call in a regular document resource like this (assuming you named it getUrl):
            [[getUrl? &url=`http://myurl.com/coldfusionscript`]]


              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              This will only work if your PHP is configured to allow external sources for the file_get_contents() function. Many shared hosts have it disabled.

              http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
                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
                • 40763
                • 7 Posts
                Scottwell. Just needed to do a iframe. Worked perfectly. I will try Mark's suggestion later.

                Thanks all for your assistance.