|
Cookbook /
GuiEditDateButtonSummary: javascript calendar to insert a date
Version: 2.0 November 2, 2006
Prerequisites: PmWiki 2
Status: Stable
Maintainer: noe
Questions answered by this recipeHow can I choose a date in a calendar and insert this date in pmwiki edit window ? DescriptionAdd a "Date" button to pmwiki guiedit toolbar When you click this "Date" button, a popup calendar appears and the selected date is inserted at the beginning of the wiki page if the focus is not in the edit zone, otherwise the date is inserted at the cursor location. Installation
$GUIButtons['date'] = array(750, '', '', '', '<a href=\"#\" onclick=\"showCalendar();\"><img src=\'$GUIButtonDirUrlFmt/date.gif\' title=\'$[Date]\' /></a>');
<link rel="stylesheet" type="text/css" media="all" href="$SkinDirUrl/calendar-win2k-cold-1.css" title="win2k-cold-1" /> <script type="text/javascript" src="$SkinDirUrl/calendar.js"></script> <script type="text/javascript" src="$SkinDirUrl/lang/calendar-en.js"></script> <script type="text/javascript" src="$SkinDirUrl/jscalendar-pmwiki.js"></script> Notes
Release Notes
Comments
$GUIButtons['sig'] = array(660, '\\n\\n* Change Log on $CurrentTime by $Author\\n\\n->', '\\n\\n', '$[Log Entry]',
'$GUIButtonDirUrlFmt/sig.gif"$[Insert Change Log on <CurrentTime> by <Author>]"');
Just append to /local/config.php, mod the text and formating to suite. It will insert at the current cursor location. Use whatever icon you like. $CurrentTime I believe is a standard variable set in pmwiki.php with the following:
$Now=time();
$TimeFmt = '%B %d, %Y, at %I:%M %p';
SDV($CurrentTime,strftime($TimeFmt,$Now));
$Author may also be a standard variable, but I'm not 100% sure what it will return if you don't have logins enable as our site has. Note, however, that the $CurrentTime variable will be set at the time the edit window was initialized and does not increment during the session. Hope this is a useful solution for different needs.
Advice: If you are using this element as a GUI button, then don't forget to copy the calendar.js, calendar-win2k-cold-1.css, jscalendar-pmwiki.js and the lang directory into the directory of the skin that you are using or you will never get it to work. A must have on all wikisites!Real Chris October 27, 2008, at 07:36 AM See Also
Contributors
|