ZexTasy
12-09-2010, 10:00 PM
First I want to thank Lynne for giving me a good startup for both code and this post from her Widget - Online Users mod.
This is a widget for your CMS pages to show Today's Birthdays.
https://vborg.vbsupport.ru/attachment.php?attachmentid=124357&stc=1&d=1292005895
You will need to Create a new Template (vbcms_widget_execphp_birthdays), Cache the template, Create a new Widget (Today's Birthdays), Configure the Widget, and then finally add the Widget to your Layout (I am not including instructions for that, you should know how to add Widgets to Layouts).
1.0 2010-12-10: First version (4.0.8)
INSTALL INSTRUCTIONS:
1) Create a new Template
Styles & Templates > select style (I like to do this in the MASTER STYLE, but you will need to reinput it after every upgrade) > Add Template
Title - vbcms_widget_execphp_birthdays
Template code -
<vb:if condition="$show['birthdays']">
<div class="cms_widget category_widget">
<div class="block">
<div class="cms_widget_header">
<h3><img src="{vb:stylevar imgdir_misc}/birthday.png" alt="{vb:rawphrase todays_birthdays}" /> {vb:rawphrase todays_birthdays}</h3>
</div>
<div class="cms_widget_content widget_content">
<div>
<ol class="commalist">
{vb:raw birthdays}
</ol>
</div>
</div>
</div>
</div>
</vb:if>
2) Create a new Plugin
Plugins & Products > Add New Plugin > leave everything default except:
Hook Location - cache_templates
Title - Cache template for Today's Birthdays Widget
Plugin PHP code -
if (THIS_SCRIPT == 'vbcms')
{
$cache[] = 'forumhome_birthdaybit';
}
Plugin is Active - Yes
3) Create a new Widget
vBulletin CMS > Widgets > Create New Widget
Widget Type - PHP Direct Execution
Title - Today's Birthdays
SAVE
4) Configure the Widget
Now go to vBulletin CMS > Widgets > Today's Birthdays > Configure
Change the Template Name to -
vbcms_widget_execphp_birthdays
Add the following code -
$today = vbdate('Y-m-d', TIMENOW, false, false);
// ### TODAY'S BIRTHDAYS #################################################
if (vB::$vbulletin->options['showbirthdays'])
{
if (!is_array(vB::$vbulletin->birthdaycache)
OR ($today != vB::$vbulletin->birthdaycache['day1'] AND $today != vB::$vbulletin->birthdaycache['day2'])
OR !is_array(vB::$vbulletin->birthdaycache['users1'])
)
{
// Need to update!
require_once(DIR . '/includes/functions_databuild.php');
$birthdaystore = build_birthdays();
DEVDEBUG('Updated Birthdays');
}
else
{
$birthdaystore = $vbulletin->birthdaycache;
}
switch ($today)
{
case $birthdaystore['day1']:
$birthdaysarray = $birthdaystore['users1'];
break;
case $birthdaystore['day2']:
$birthdaysarray = $birthdaystore['users2'];
break;
default:
$birthdaysarray = array();
}
// memory saving
unset($birthdaystore);
$birthdaybits = array();
foreach ($birthdaysarray AS $birthday)
{
$templater = vB_Template::create('forumhome_birthdaybit');
$templater->register('birthday', $birthday);
$birthdaybits[] = $templater->render();
}
$birthdays = implode('', $birthdaybits);
$show['birthdays'] = iif ($birthdays, true, false);
}
else
{
$show['birthdays'] = false;
}
$birthdaysarray = array('birthdays' => $birthdays,
'show' => $show,
);
vB_Template::preRegister('vbcms_widget_execphp_bir thdays', $birthdaysarray);
After install clear the CMS cache
This is a widget for your CMS pages to show Today's Birthdays.
https://vborg.vbsupport.ru/attachment.php?attachmentid=124357&stc=1&d=1292005895
You will need to Create a new Template (vbcms_widget_execphp_birthdays), Cache the template, Create a new Widget (Today's Birthdays), Configure the Widget, and then finally add the Widget to your Layout (I am not including instructions for that, you should know how to add Widgets to Layouts).
1.0 2010-12-10: First version (4.0.8)
INSTALL INSTRUCTIONS:
1) Create a new Template
Styles & Templates > select style (I like to do this in the MASTER STYLE, but you will need to reinput it after every upgrade) > Add Template
Title - vbcms_widget_execphp_birthdays
Template code -
<vb:if condition="$show['birthdays']">
<div class="cms_widget category_widget">
<div class="block">
<div class="cms_widget_header">
<h3><img src="{vb:stylevar imgdir_misc}/birthday.png" alt="{vb:rawphrase todays_birthdays}" /> {vb:rawphrase todays_birthdays}</h3>
</div>
<div class="cms_widget_content widget_content">
<div>
<ol class="commalist">
{vb:raw birthdays}
</ol>
</div>
</div>
</div>
</div>
</vb:if>
2) Create a new Plugin
Plugins & Products > Add New Plugin > leave everything default except:
Hook Location - cache_templates
Title - Cache template for Today's Birthdays Widget
Plugin PHP code -
if (THIS_SCRIPT == 'vbcms')
{
$cache[] = 'forumhome_birthdaybit';
}
Plugin is Active - Yes
3) Create a new Widget
vBulletin CMS > Widgets > Create New Widget
Widget Type - PHP Direct Execution
Title - Today's Birthdays
SAVE
4) Configure the Widget
Now go to vBulletin CMS > Widgets > Today's Birthdays > Configure
Change the Template Name to -
vbcms_widget_execphp_birthdays
Add the following code -
$today = vbdate('Y-m-d', TIMENOW, false, false);
// ### TODAY'S BIRTHDAYS #################################################
if (vB::$vbulletin->options['showbirthdays'])
{
if (!is_array(vB::$vbulletin->birthdaycache)
OR ($today != vB::$vbulletin->birthdaycache['day1'] AND $today != vB::$vbulletin->birthdaycache['day2'])
OR !is_array(vB::$vbulletin->birthdaycache['users1'])
)
{
// Need to update!
require_once(DIR . '/includes/functions_databuild.php');
$birthdaystore = build_birthdays();
DEVDEBUG('Updated Birthdays');
}
else
{
$birthdaystore = $vbulletin->birthdaycache;
}
switch ($today)
{
case $birthdaystore['day1']:
$birthdaysarray = $birthdaystore['users1'];
break;
case $birthdaystore['day2']:
$birthdaysarray = $birthdaystore['users2'];
break;
default:
$birthdaysarray = array();
}
// memory saving
unset($birthdaystore);
$birthdaybits = array();
foreach ($birthdaysarray AS $birthday)
{
$templater = vB_Template::create('forumhome_birthdaybit');
$templater->register('birthday', $birthday);
$birthdaybits[] = $templater->render();
}
$birthdays = implode('', $birthdaybits);
$show['birthdays'] = iif ($birthdays, true, false);
}
else
{
$show['birthdays'] = false;
}
$birthdaysarray = array('birthdays' => $birthdays,
'show' => $show,
);
vB_Template::preRegister('vbcms_widget_execphp_bir thdays', $birthdaysarray);
After install clear the CMS cache