I'm trying to create an AJAX image switcher for different Colored Product.
In my Page_Controller id added
if(Director::is_ajax() || $_GET["ajaxDebug"]) {
$this->isAjax = true;
}
else {
$this->isAjax = false;
}
Then in my ColorProduct Page Controller I added:
function index() {
if($this->isAjax) {
return $this->renderWith("ColorProductXML");
}
else {
return Array();
}
}
I then created a ColorProductXML tempalte and placed it in my root template directory
<?xml version="1.0" encoding="UTF-8"?>
<colorproduct>
<% control Colors %>
<color colorID="$StripColorName">
<name>$ColorName</name>
<hex>$ColorHex</hex>
<% control ToyImageClasss %>
<imagegroup imageName="$StripImageName">
<type>$ImageClass</type>
<% control ToyImages %>
<% if Type=="Normal" %>
<% control Attachment %>
<thumbnail>$SetWidth(60).URL</thumbnail>
<small>$SetWidth(460).URL</small>
<zoom>$SetWidth(920).URL</zoom>
<full>$URL</full>
<% end_control %>
<% end_if %>
<% if Type=="Blur" %>
<blur>$Attachment.URL</blur>
<% end_if %>
<% end_control %>
</imagegroup>
<% end_control %>
</color>
<% end_control %>
</colorproduct>
When I access a ColorProduct page adding ?ajax=1 to the end of my URL I get nice XML document, and my jQuery call to that url also returns a document in the same format but I can't query the nodes. Firebug shows the Content-Type as text/html instead of application/xml. How do I force SS to return an XML content type?