Copied to clipboard

Flag this post as spam?

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


  • cardinal252 21 posts 33 karma points
    May 26, 2009 @ 14:06
    cardinal252
    0

    Adding global XML to umbraco objects

    Is there any way, before I look into modifying the codebase, that you can add custom xml directly into the umbraco core xml, or universally accessible xml from say a user control / extended page using the Umbraco framework.

    The reasoning for this is that we have a hell of a lot of core data utilised from external webservices that quite often needs custom logic wrapped around to determine whether the display or not.

    I have a plan for how to modify umbraco to accept this should it not available out of the box, but wanted to know if was possible in some other manner.

    I have already investigated the idea of used the library GetXmlFromUrl method, but would prefer a more core solution

    Any Thoughts??

    Thank you in advance

  • Daniel Lindstrom 454 posts 271 karma points
    May 26, 2009 @ 14:33
    Daniel Lindstrom
    0

    It is super simple to add data to the umbraco XML in memory cache, even without core hacks, but it would get lost on every publish. Maybe you could catch the publish event to handle this.

    What are your reasons for wanting 'a more core solution'?

    With XSLT you can fetch external data to XSLT and process it, with GetXmlFromUrl as you described.

    Or a custom XSLT extension that fetches the data and process it in C# and then returns processed data to xslt.

    You could also use a user control for this.

    I have used all three options on different umbraco sites.

    There are many solutions for this, but modifying the core does not seem like a good option unless you have some very specific needs that cannot be handled any other way.

  • cardinal252 21 posts 33 karma points
    May 26, 2009 @ 14:52
    cardinal252
    0

    The data that is brought back will ideally be utilized pretty much throughout the page - xslt and non xslt returns preferably, this is to include right the way from titles to footer links.

    - It needs to be dependant on query strings coming back from urlrewriting net

    e.g. http://www.domain.co.uk/region/county/town/cars/make/model

    rewritten internally to default.asp?region=$1&town=$2&county=$3&make=$4&model=$5

    - It needs to be pulled in dynamically on every page load on a page by page basis

    - It needs to allow me to redirect the page in the event of invalid data - ie: a region / county / town combination where the town is incorrect redirects to the correct region / county omitting the "Bad" town

    - Ideally it would allow me to provide a replacement mechanism globally across the document to allow this to managed from a handful of umbraco nodes - ie: in the example above, the you could assign a page title of ##Make## cars in ##Region## and it would replace the ##Make## and ##Region## with the appropriate values pulled from the web services, same in any other text elements for the page

    User controls are too modular, and I would essentially have to write the whole page in them to make it work the way I want it to.

    GetXmlFromUrl would mean I have to do all of the logic coding in pure xslt, so basically the whole template would be a macro. However, I haven't found a way to redirect (and don't think it would be possible from the xslt side)

    My general thoughts for modification to allow this scenario would be to take the code from default.aspx and place it into a seperate class that you could then inherit from, this would then potentially allow you to override page events to perform the tasks above for "special" pages

    This was how I achieved the above effect in my custom written cms (which is similar in design to umbraco)

    Thank you in advance for any further help

  • Daniel Lindstrom 454 posts 271 karma points
    May 26, 2009 @ 17:16
    Daniel Lindstrom
    0

    OK, you do not want to make the whole page a user control or xslt macro, as you put it. Still you need the date fetched externally once to be accessible throught out the whole page.

    There should be several solutions for this, without hacking the core. A very simple solution would be to put the fields you need populated with external data as asp controls in the template. Then fetch the data in the template using

  • cardinal252 21 posts 33 karma points
    May 26, 2009 @ 17:49
    cardinal252
    0

    Hey Daniel, it is a viable method, but I don't think you could then access the data in the xslt macros then though could you?? Also, you would have to duplicate that code on each page as opposed to running it in a code behind.

    In addition, I would have to put quite a bit of logic into the top of the page and throughout the page to make it work using that solution. I already have probably 1000+ lines of code across a number of classes that control the logic for structures for the various scenarios over and above the existing CMS data that we utilise that originally simply extends the .net Page object.

    I would definately ideally prefer to keep it seperate concerns from the layout where possible and would prefer not to place that amount of code inline on a page.

    I might look into restructuring our data a little, but suspect the amount of work required without modifying the umbraco core would make if prohibitively time consuming. I definately feel thusfar that being able to inherit a base umbraco page would ultimately make umbraco a more extensible framework (not that it isn't already)...

    I do think its a fantastic framework, I just need to figure out how best to achieve what I need to do

  • cardinal252 21 posts 33 karma points
    May 27, 2009 @ 12:47
    cardinal252
    0

    Any more thoughts on an elegant solution to these issues?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    May 27, 2009 @ 13:07
    Ismail Mayat
    0

    cardinal252,

    You should not have a need to modify core, with a little bit of thought and engineering all that you need could be accomplished using .net /xslt macros and xslt extensions (this is how you could do redirect in xslt).


    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft