Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Steven Howard 5 posts 25 karma points
    Nov 12, 2010 @ 11:47
    Steven Howard
    0

    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

  • daniel_sbbs 33 posts 52 karma points
    Nov 12, 2010 @ 12:27
    daniel_sbbs
    0

    Can't you create a new template and call a macro in that template which uses the currentPage value to output the XML?

  • Steven Howard 5 posts 25 karma points
    Nov 12, 2010 @ 13:03
    Steven Howard
    0

    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

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Nov 12, 2010 @ 13:13
    Ravi Motha
    0

    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

     

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Nov 12, 2010 @ 13:14
    Ravi Motha
    0

    or do you want to be able to switch any page to a XML page via a switch or something else?

  • Steven Howard 5 posts 25 karma points
    Nov 12, 2010 @ 13:25
    Steven Howard
    0

    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

  • Rich Green 2246 posts 4008 karma points
    Nov 12, 2010 @ 14:13
    Rich Green
    0

    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

  • Rich Green 2246 posts 4008 karma points
    Nov 12, 2010 @ 14:14
    Rich Green
    0

    More info on alttemplate here http://www.nibble.be/?p=42

    Rich

  • Ravi Motha 290 posts 500 karma points MVP 8x c-trib
    Nov 12, 2010 @ 14:22
    Ravi Motha
    0

    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

  • Steven Howard 5 posts 25 karma points
    Nov 12, 2010 @ 14:32
    Steven Howard
    0

    Thanks Rich, that's exactly what I wanted and works a treat.

    Thank you Ravi and Daniel also

    Steven

     

Please Sign in or register to post replies

Write your reply to:

Draft