Thread: Mini Calendar
View Single Post
  #7  
Old 08-11-2009, 04:29 AM
Vector76 Vector76 is offline
 
Join Date: Jul 2009
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I put something together that appears to work. Basically I took a very carefully chosen few lines from calendar.php, just enough to get the mini calendar to work. Here's the php in its entirety:
PHP Code:
<?php
require_once(DIR '/includes/functions_calendar.php');
$today getdate(TIMENOW $vbulletin->options['hourdiff']);
$vbulletin->GPC['month'] = $today['mon'];
$vbulletin->GPC['year'] = $today['year'];

$usertoday = array(
    
'firstday' => gmdate('w'gmmktime(000$month1$year)),
    
'day' => $vbulletin->GPC['day'],
    
'month' => $vbulletin->GPC['month'],
    
'year' => $vbulletin->GPC['year'],
);
// NOTE! Hard-coded for calendar number 1!
$vbulletin->GPC['calendarid'] = 1;
$calendarinfo verify_id('calendar'$vbulletin->GPC['calendarid'], 11);
$getoptions convert_bits_to_array($calendarinfo['options'], $_CALENDAROPTIONS);
$calendarinfo array_merge($calendarinfo$getoptions);
$geteaster convert_bits_to_array($calendarinfo['holidays'], $_CALENDARHOLIDAYS);
$calendarinfo array_merge($calendarinfo$geteaster);

$eventrange = array();
$eventrange['frommonth'] = $vbulletin->GPC['month'];
$eventrange['fromyear']= $vbulletin->GPC['year'];
$eventrange['nextmonth'] = $vbulletin->GPC['month'];
$eventrange['nextyear'] = $vbulletin->GPC['year'];
$eventcache cache_events($eventrange);

$minimonth construct_calendar_output($today$usertoday$calendarinfo);
?>
I named this file cal.php.

Then within index.php (i wanted it on the main page only), right after
PHP Code:
require_once('./global.php'); 
I put
PHP Code:
require_once('./cal.php'); 
Then the last step is, within the template, wherever you want the mini calendar to appear, place this (the same fragment that appears on the monthly calendar).
HTML Code:
<table class="tborder" cellpadding="2" cellspacing="$stylevar[cellspacing]" border="0" width="170">
$minimonth
</table>

So, to summarize:
1. copy the php code into a file, cal.php and put that file in the main forum directory
2. add php code to require_once this file, in the file where you want to use the mini calendar
3. add the <table> fragment including $minimonth to your template.

Note, I don't really understand how the multiple calendars work, or the access control for calendars, so this is hard-coded to always display calendar 1.

If someone else wants to turn this into an official "mod" then by all means go ahead.

Attached is a screen shot (I put it on the FAQ page first so as not to disrupt the forum during development).
Attached Images
File Type: png calendar.png (28.7 KB, 0 views)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01390 seconds
  • Memory Usage 1,826KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete