Full CDN without the need of iframes

keraweb

New member
This is not a support question

It's simply a topic for anyone who want's everything external without the use of iFrames.

I've accomplished this by adding a simple PHP script in the root of my website:

filename: external_config_loader.php
Code:
<?php

$url = $_GET['xmlurl'];

$info = pathinfo( $url );
if ( $info['extension'] != 'xml' ) {
	exit( 'Not a XML file.' );
}

$file = file_get_contents( $url );

header("Content-type: text/xml");
echo $file;

exit();

This simply avoids the cross-domain problems by loading it with PHP and echo the same output as XML for use as your config file.

Your product config will still use the same two parameters (path and root).

Path: **Your url to your external .xml file"
Root:**The root folder, normally the same folder as your .xml file resides in**

JS implementation (in this example it's Magento):

Code:
<?php if ( strpos( $_360path, 'http' ) !== false ): ?>
    _imageRotator.settings.configFileURL = "http://www.yoursite.domain/external_config_loader.php?xmlurl=<?php echo $_360path ?>";
<?php else: ?>
    _imageRotator.settings.configFileURL = "http://www.yoursite.domain/<?php echo $_360path ?>";
<?php endif ?>

This first checks if the path is an external path, if so, calls the external_config_loader.php file with the path as a get variable.

The location of files etc is depending on your type of implementation but this will give an idea.

@webrotate360 team, this can easally be implementated in any plugin for popular CMS systems.

Just wanted to share :)
 

keraweb

New member
Hi @blackwat3r,

This all depends on your implementation.
You can use the JS code to extend your current code.

In my case it was a Magento template and that is the code you see in the example.

I'll explain the code a bit:

Code:
<?php if ( strpos( $_360path, 'http' ) !== false ): ?>

Here it checks for the variable $_360path.
This name could be anything depending on your implementation. In my case, it gets the value from a Magento attribute.

- If this value is a full/absolute URL ('http://...') it gets the XML with the PHP script.
- If not (relative URL) it gets it with a direct link to the XML file.
 
Top