Copied to clipboard

Flag this post as spam?

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


  • Tom Steer 24 posts 44 karma points
    Oct 21, 2010 @ 11:18
    Tom Steer
    0

    Custom Table for Document Type Properties

    Hey Guys,

    I'm pretty new to umbraco but i must say i'm loving it already :)

    I thinking about using it for a project i have at the moment (B&B Booking System) but i had a quick question.

    For the different rooms i was planning on using a document type and naming it room.

    Would it be possible to save the properties from this document in a custom table in the database?

    Cheers :)

     

    Tommyflint

  • Sascha Wolter 615 posts 1101 karma points
    Oct 21, 2010 @ 11:54
    Sascha Wolter
    0

    Hi Tom,

    this is definitely possible, the easiest way is probably to hook up to the document publish event and save/update the details to your custom database when a Room type gets published (see the video tutorials for more info).

    However the question is why you want to do that in the first place? If you need other systems to retrieve this information from your website you can write web services for that, if you want to extract the information or have a customized overview you can put together e.g. a dashboard in the backend. If you let us know your intentions there might be a better way to achieve what you have in mind. :)

    Sascha

  • Tom Steer 24 posts 44 karma points
    Oct 21, 2010 @ 12:47
    Tom Steer
    0

    Hi Sascha,

    Thanks for the reply

    Well basically what I indend to do is have a two different document types one for sites e.g. different B&B's and one for rooms which can be childs of the sites

    My intial reason for maybe having it in a seperate table is during the booking process i need to access data about that room for example what the mininum number of nights that room can be booked for and or the pricing for that room etc... its probably becuase i'm not eniterly sure of the umbraco data structure and how easy it would be to retrive this data once at the booking stage.

    Cheers

    Tommy

     

     

  • Sascha Wolter 615 posts 1101 karma points
    Oct 21, 2010 @ 13:56
    Sascha Wolter
    0

    Hi Tom,

    in that case I would most likely go either with web services to get you that information or get the info from the node yourself if the booking is part of the Umbraco web application. Let's say somebody booked a B&B with the id 2345 (aka id of the node in Umbraco) and the room at that B&B with node id of 2555, then you can do the following in your backend:

    Node bAndB = new Node(2345);

    Node room = new Node(2555);

    string bAndBAddress = bAndB.getProperty("address").Value.ToString(); //assuming there is such a property

    string roomNumber = room.getProperty("number").Value.ToString();

    The ids would obviously by dynamic depending on what the user has selected. The above basic code outline works for both scenarios. 

    Hope that helps,

    Sascha

  • Tom Steer 24 posts 44 karma points
    Oct 21, 2010 @ 14:26
    Tom Steer
    0

    Thank you for all the guidance Sascha its very kind of you :)

    Is there any tutorials on utilizing the document information in custom controls as for the booking process i would build a custom control and then drop it on the Room Document Type but i'm not sure how i can access the current page information when making the control?

    Once again thanks for all the help :)

    Tom

     

    EDIT:

    Ahh i'm learning :) just found this: http://our.umbraco.org/wiki/reference/templates/umbracomacro-element

     

  • Sascha Wolter 615 posts 1101 karma points
    Oct 21, 2010 @ 15:44
    Sascha Wolter
    0

    Hi Tom,

    glad I can help out. :) The video tutorials are probably the best way to get you started in Umbraco, they give you a good overview of how things work in Umbraco and where you can extend the build-in functionality via custom code. 

    The Wiki contains also lots of tips and tricks on specific areas, it can be found here. E.g. a search for 'document' gives you a couple of topics to start with.

    As to your question: you can use custom .Net controls in multiple ways with Umbraco, e.g. as a custom data type, as macro called from a template, as custom Xslt extension, and a couple more ways. In your case for the booking process you would most likely use a .Net usercontrol as macro on a template. You can then e.g. hold the selected bookings of a user in Session variable(s) which you can then access via the user control.

    In my humble opinion the quickest way to get up to speed with Umbraco is to watch the fabulous Umbraco.tv footage and have an Umbraco installation at hand where you can do it yourself while watching.

    Hope that helps,

    Sascha

Please Sign in or register to post replies

Write your reply to:

Draft