I want to create a site where each content page can be easiliy outputted as XML via the page URL.For example something along the lines of http://domain/folder/page.aspx?xml=1.
I can achieve what I want by creating a dedicated page utilising umbraco.library:GetXmlNodeById() and pass the page id as a querystring but I was hoping for a neater solution such that I can easilily get the XML without needing to get the id first. I would rather avoid creating a custom control so was hoping there is a solution using the native controls.
Apologies but I'm a bit of an Umbraco novice. Here's my train of thought. If I created the site with a core master template and maybe several content templates, I would need a conditional statement to determine whether to output the page as normal HTML or XML. However, this would need to happen at the start of the page processing to change the content type to xml, ie in the master template. At this point my train of thought derails and crashes. Unfortunately I don't then follow how to implement your suggestion into my train of thought.
The Suggestion by Rich is the most practical way of doing this, as you can gradually add extra templates and also control it all within the umbraco environment without having to masses of extra coding
Getting XML of page from URL
Hi
I want to create a site where each content page can be easiliy outputted as XML via the page URL.For example something along the lines of http://domain/folder/page.aspx?xml=1.
I can achieve what I want by creating a dedicated page utilising umbraco.library:GetXmlNodeById() and pass the page id as a querystring but I was hoping for a neater solution such that I can easilily get the XML without needing to get the id first. I would rather avoid creating a custom control so was hoping there is a solution using the native controls.
Any assistance greatly appreciated
Steven
Can't you create a new template and call a macro in that template which uses the currentPage value to output the XML?
Hi Daniel
Apologies but I'm a bit of an Umbraco novice. Here's my train of thought. If I created the site with a core master template and maybe several content templates, I would need a conditional statement to determine whether to output the page as normal HTML or XML. However, this would need to happen at the start of the page processing to change the content type to xml, ie in the master template. At this point my train of thought derails and crashes. Unfortunately I don't then follow how to implement your suggestion into my train of thought.
Many thanks
Steven
Am I right in thinking you want to do some like this: forgive the pseudo code
in master page
on page load (some page event)
determine page
change content type for display
or do you want to be able to switch any page to a XML page via a switch or something else?
Hi Ravi
My goal is to be able to output any page on the site as html or xml from the URL via a switch such as a querystring parameter.
Eg
HTML:- http://domain/landingpage/subpage1.aspx
XML:- http://domain/landingpage/subpage1.aspx?xml=true
and for this to work with any page on the site and any subsequent page I add.
Regards
Steven
Hi Steven,
If i've understood you correctly you can just use
http://domain/landingpage/subpage1.aspx?alttemplate=nameofyourxmltemplate
Basically every doc type can have multiple templates so in one you can display content and in the other template just get your macro to output xml.
Hope I understood your issue
Rich
More info on alttemplate here http://www.nibble.be/?p=42
Rich
The Suggestion by Rich is the most practical way of doing this, as you can gradually add extra templates and also control it all within the umbraco environment without having to masses of extra coding
Thanks Rich, that's exactly what I wanted and works a treat.
Thank you Ravi and Daniel also
Steven
is working on a reply...