Hours of Operation Field Type

  0 rating
8/17/2015 7:24:43 PM
8/24/2015 10:27:24 AM
Source: GitHub
Provider: DEG

About

This field type provides an easy to use interface for your content authors to select which days and times that their company is open.  The value is saved as XML which makes it easy for you to parse and display on the site.

Documentation

Documentation
  • Documentation > Install
    Install

    This project uses TDS to bring all of your Sitecore items into Visual Studio.  Once you pull down the solution, please follow these steps:

    1. Add a reference to Sitecore.Kernel under DEG.SC.HoursOfOperation.Web.  This will allow the solution to build properly.
    2. Update the 'Sitecore Web Url' and 'Sitecore Deploy Folder' for DEG.SC.HoursOfOperation.TDS.Core. This will allow you to add the needed items to your Sitecore instance.
    3. Update the associated publish profile(s) for your development environment.
    4. Sync items in DEG.SC.HoursOfOperation.TDS.Core with your local Sitecore instance.
    5. Publish the solution.
    0
  • Documentation > Page Editor
    Page Editor

    In order to make this as page editor friendly as possible, I recommend using an edit frame.  This greatly improves the page editor experience by not displaying the raw value.

    1
  • Documentation > Saving Value From Content Editor
    Saving Value From Content Editor

    Below I will detail the steps to saving the hours of operation using the content editor.

    1. Click the 'Edit' button directly above the name of the field. Don't see this button? Make sure the files under App_Config and sitecore modules have been published.
    2. Set the appropriate values in the modal that appears.  Note: Checking the '24 Hours' checkbox will disable the rest of the modal.  Likewise, selecting 'Closed' on a specific day of the week will disable the drop downs for that day.
    3. Click 'OK'
    4. Save.  The box displaying the times will not update until the item has been saved.
    2
Back
Release notes
v1.0.0. Tested in Sitecore 7.2 but will probably work fine with 7.0+
Read more Back
Code examples
  • Code examples > Create Model From Raw Value
    Create Model From Raw Value

    Instantiating the HoursOfOperationModel from the raw value stored in Sitecore is very easy.  The model contains a constructor which will accept the raw value from Sitecore and take care of any sanitizing that may need to occur for you.  


    Example: var model = new HoursOfOperationModel(rawXmlValue);

    1
  • Code examples > Serialize Model To Raw Value
    Serialize Model To Raw Value

    Creating the raw value to save in Sitecore from the HoursOfOperationModel is done by using an XmlSerializer, which does the work for us.  See the example method below.


    Example:

    private string SerializeModelToRawValue(HoursOfOperationModel model)
    {
    var serializer = new XmlSerializer(typeof(HoursOfOperationModel));
    var stringwriter = new StringWriter();

    serializer.Serialize(stringwriter, model);

    return stringwriter.ToString();
    }

    1

Solution screenshots(0)

Upload

Reviews (0)

Sort by: Date Most votes
  • Profile Avatar
    [fullName]

    Level: 0

    x0 x0 x0

    [date]

    [title]

    [text]

    Was this helpful?

    0

Comments (0)

Sort by: Date  Most votes

Leave a Comment

Comment must be field in
Post comment
loader

Write a review

Title can't be empty
Review can't be empty
Post review

Download

Title Description Download Action

Add File