It is possible to build a custom data-type to do this, but it depends how much time/effort you want to put into it?
Would you need to use this data-type more than once per website? If not then I'd suggest have separate textfield properties for each of the days, then the user can enter the times, or a label (e.g. "Closed").
If it will be used a lot - and the only example I can currently think of is a Business Listings website, (that displays the opening times) ... then yes, it's probably work developing a custom data-type.
How is your .NET code? Couple of ways to tackle it... either using the user-control wrapper, or as a "native" data-type, (using classes).
I'd say that pretty much depends on what you want to do with the info later on. E.g. if it's just used to display the opening hours of a shop on the frontend then you would probably be alright with using just a textbox of kinds. However if you want to react programmatically to the information given then you'd probably need to create your own type, although you could also achieve this with a combination of dropdowns, e.g. create 7 'sections' (one for each day) consisting of 2 dropdowns displaying hours 0:00 to 23:00. If nothing is entered then the store is closed.
Obviously you can also create a nice control, for instance a datatype that wraps a usercontrol, and then store the information like this:
08:00-16:00, 09:00-18:00, closed, ...
There are a couple of very nice tutorial videos on umbraco.org on how to create your own datatype based on a usercontrol.
The deluxe version would be a nice and slick week grid with nice and intuitive controls to select the timings for a day, then store the data as xml like
<schedule>
<Monday>
<start>08:00</start>
...
yet to be honest - as nice as this would be - it might be a bit overkill.
I completely agree when you say much depends on how the data or control will be used.
In my case many backend users will have to input their opening hours, so I really feel a custom user control would enhance user experience and restrict input for that matter.
I have not yet implemented a datatype based on a user control, but I think this may be a good opportunity to try & learn ;-)
The datatype storing XML data indeed sounds like a good place to start from, Sascha.
i would just use the custom repeatable content dataType from the projects section... create a new dataType of storeHours and give it properties for day,openTime, closeTime and put it on yoru homepage node or store node.
I know it's out of the post but have you managed to make the cusotm contant datatype work with 4.5.2 version? I see there is no support yet. Am I wrong?
If yes, is it under 3.5 .net or 4? If you do have .net 4 and works for the 4.5.2 could you just email it to me to test it please?
Schedule data type?
Hi,
I would like to enable the backend users to configure a list of opening hours (a schedule if you will) for a specific document type.
- Monday 8:00 - 16:00
- Tuesday 9:00 - 18:00
- Wednesday Closed
What would be the best way to accomplish this?
Should I create a custom data type?
If so, how can I store & retrieve the selected values?
Your feedback is highly appreciated.
Thanks!
Hi Lennart,
It is possible to build a custom data-type to do this, but it depends how much time/effort you want to put into it?
Would you need to use this data-type more than once per website? If not then I'd suggest have separate textfield properties for each of the days, then the user can enter the times, or a label (e.g. "Closed").
If it will be used a lot - and the only example I can currently think of is a Business Listings website, (that displays the opening times) ... then yes, it's probably work developing a custom data-type.
How is your .NET code? Couple of ways to tackle it... either using the user-control wrapper, or as a "native" data-type, (using classes).
Cheers, Lee.
Hi Lennart,
I'd say that pretty much depends on what you want to do with the info later on. E.g. if it's just used to display the opening hours of a shop on the frontend then you would probably be alright with using just a textbox of kinds. However if you want to react programmatically to the information given then you'd probably need to create your own type, although you could also achieve this with a combination of dropdowns, e.g. create 7 'sections' (one for each day) consisting of 2 dropdowns displaying hours 0:00 to 23:00. If nothing is entered then the store is closed.
Obviously you can also create a nice control, for instance a datatype that wraps a usercontrol, and then store the information like this:
08:00-16:00, 09:00-18:00, closed, ...
There are a couple of very nice tutorial videos on umbraco.org on how to create your own datatype based on a usercontrol.
The deluxe version would be a nice and slick week grid with nice and intuitive controls to select the timings for a day, then store the data as xml like
<schedule>
<Monday>
<start>08:00</start>
...
yet to be honest - as nice as this would be - it might be a bit overkill.
Hope that helps,
Sascha
Hey guys,
Thanks for your quick replies!
I completely agree when you say much depends on how the data or control will be used.
In my case many backend users will have to input their opening hours, so I really feel a custom user control would enhance user experience and restrict input for that matter.
I have not yet implemented a datatype based on a user control, but I think this may be a good opportunity to try & learn ;-)
The datatype storing XML data indeed sounds like a good place to start from, Sascha.
Thanks for your insights gentlemen!
Greetz
Lennart
i would just use the custom repeatable content dataType from the projects section... create a new dataType of storeHours and give it properties for day,openTime, closeTime and put it on yoru homepage node or store node.
it is an awesome dataType, btw...
http://our.umbraco.org/projects/backoffice-extensions/repeatable-custom-content
Hi Bob,
I was able to set up the repeatable custom content datatype on Umbraco 4.5.2 and customize it accordingly.
Excellent datatype, thanks for pointing it out!
Hi Lennart,
I know it's out of the post but have you managed to make the cusotm contant datatype work with 4.5.2 version? I see there is no support yet. Am I wrong?
If yes, is it under 3.5 .net or 4? If you do have .net 4 and works for the 4.5.2 could you just email it to me to test it please?
info (at) primecut (dot) gr
Thanks! Giorgos
Hello Giorgos,
I have installed the repeatable content datatype (V2 fixed) and used it as the render control for my custom datatype.
It is running perfect in Umbraco 4.5.2 / .NET 4, and I did not experience any issues so far :-)
Hey Lennart,
I just tried it and seems more than fine, that's great news for me. I can go on now!
Cheers! Giorgos
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.