Monday, April 2, 2012

Calendar._MN is undefined magento

Today i was implementing caledar feature in frontend. I have included all the required js and css file for that.
<link rel="stylesheet" type="text/css" href="http://www.beds.sg/v2/js/calendar/calendar-win2k-1.css" />
<script type="text/javascript" src="http://www.beds.sg/v2/js/calendar/calendar.js"></script>
<script type="text/javascript" src="http://www.beds.sg/v2/js/calendar/calendar-setup.js"></script>

Still it was showing this error."Calendar._MN is undefined"
After some R&D i found out that i missed to include some javascript that is necessary for calendar to work.
I just included following lined on the page and it begins to work smoothly.

<script type="text/javascript">
//<![CDATA[
enUS = {"m":{"wide":["January","February","March","April","May","June","July","August","September","October","November","December"],"abbr":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}}; // en_US locale reference
Calendar._DN = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; // full day names
Calendar._SDN = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; // short day names
Calendar._FD = 0; // First day of the week. "0" means display Sunday first, "1" means display Monday first, etc.
Calendar._MN = ["January","February","March","April","May","June","July","August","September","October","November","December"]; // full month names
Calendar._SMN = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; // short month names
Calendar._am = "AM"; // am/pm
Calendar._pm = "PM";

// tooltips
Calendar._TT = {};
Calendar._TT["INFO"] = "About the calendar";

Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" +
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";

Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
Calendar._TT["GO_TODAY"] = "Go Today";
Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
Calendar._TT["SEL_DATE"] = "Select date";
Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
Calendar._TT["PART_TODAY"] = ' (' + "Today" + ')';

// the following is to inform that "%s" is to be the first day of week
Calendar._TT["DAY_FIRST"] = "Display %s first";

// This may be locale-dependent. It specifies the week-end days, as an array
// of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1
// means Monday, etc.
Calendar._TT["WEEKEND"] = "0,6";

Calendar._TT["CLOSE"] = "Close";
Calendar._TT["TODAY"] = "Today";
Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";

// date formats
Calendar._TT["DEF_DATE_FORMAT"] = "%b %e, %Y";
Calendar._TT["TT_DATE_FORMAT"] = "%B %e, %Y";

Calendar._TT["WK"] = "Week";
Calendar._TT["TIME"] = "Time:";

CalendarDateObject._LOCAL_TIMZEONE_OFFSET_SECONDS = -28800;
CalendarDateObject._SERVER_TIMZEONE_SECONDS = 1333496531;

//]]>
</script>


14 comments:

  1. tnanx bhaiya you save my time gr8 work.....

    ReplyDelete
  2. you are welcome bro. Glad to know it saved some time for you.

    ReplyDelete
  3. What you've done here is statically copied the output of a block from the Admin section of Magento, specifically app\design\adminhtml\default\default\template\page\js\calendar.phtml

    However, if you want to include this dynamically so that it updates along with your site's locale settings, you should include that block in your page's Layout XML, like so:

    ReplyDelete
  4. What you've done here is statically copied the output of a block from the Admin section of Magento, specifically app\design\adminhtml\default\default\template\page\js\calendar.phtml

    However, if you want to include this dynamically so that it updates along with your site's locale settings, you should include that block in your page's Layout XML, like so:

    <reference name="content"><block type="core/html_calendar" name="head.calendar" as="calendar" template="page/js/calendar.phtml"/></reference>

    ReplyDelete
  5. Thanks Prashant, You really saved my day.

    ReplyDelete
  6. Just one note

    CalendarDateObject._LOCAL_TIMZEONE_OFFSET_SECONDS = -28800;
    CalendarDateObject._SERVER_TIMZEONE_SECONDS = 1333496531;

    forcing the calendar to start with the today date as 3rd April 2012, so if we remove this it will get the current date.

    Thanks

    ReplyDelete
  7. Thank's Work perfectly

    ReplyDelete
  8. thanks friend nice work :) Akshat

    ReplyDelete
  9. This is a great post. I like this topic.This site has lots of advantage. It helps me in many ways.Thanks for posting this again.
    magento development company in bangalore 

    ReplyDelete