Wednesday 07 April 2010 2:53:26 am
Hi Edwidge, just alter an existing content-class (or create a new one) and add a file attribute to it (name it for example xml_file). Create a contentobject from this class and upload the xml-file to the xml_file attribute. Than you can acess the full path to the xml-file in a template by first fetching the content object and than accessing the xml_file attribute via the objects data_map. (In this example the content_object is assigned to node_id 100, the name of the file attribute is xml_file)
{def $myFileObject = fetch( 'content', 'node', hash( 'node_id', 100))}
{def $myFileURL = $myFileObject.data_map.xml_file.content.filepath|ezroot}
{* Now use it in your javascript *}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var xmlfile = '{$myFileURL}';
{literal}
$(document).ready(function()
{
$.ajax({
type: "GET",
url: xmlfile,
dataType: "xml",
success: doSomethingWithXML
});
});
doSomethingWithXML = function( data )
{
// your code to deal with the xml
}
{/literal} Hope you got the idea.
Best regards,
Patrick
|