Full CDN without the need of iframes

CSS styling, controls, custom look and feel, custom packaging and deployment.
keraweb
Posts: 6
Joined: Thu Sep 08, 2016 5:35 am
Contact:

Full CDN without the need of iframes

Postby keraweb » Fri Sep 23, 2016 7:09 am

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: Select all

<?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: Select all

<?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 :)

WebSupport
Posts: 1073
Joined: Thu Aug 23, 2012 11:35 am
Location: Pasadena, CA
Contact:

Re: Full CDN without the need of iframes

Postby WebSupport » Fri Sep 23, 2016 2:01 pm

Makes sense. Thank you! 8-)

keraweb
Posts: 6
Joined: Thu Sep 08, 2016 5:35 am
Contact:

Re: Full CDN without the need of iframes

Postby keraweb » Fri Sep 30, 2016 1:11 pm

No problem :)

blackwat3r
Posts: 2
Joined: Sat Oct 01, 2016 7:24 am
Contact:

Re: Full CDN without the need of iframes

Postby blackwat3r » Sat Oct 01, 2016 7:46 am

Where do you put the JS file? Can you explain more?

keraweb
Posts: 6
Joined: Thu Sep 08, 2016 5:35 am
Contact:

Re: Full CDN without the need of iframes

Postby keraweb » Wed Oct 19, 2016 7:55 am

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: Select all

<?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.


Return to “Viewer Development and Customizations”

cron