Back to vBulletin 4.x Add-ons

Widget - Today's Birthdays
Mod Version: 1.00, by ZexTasy

vB Version: 4.0.8 Rating: (3 votes - 3.33 average) Installs: 49
Released: 10 Dec 2010 Last Update: 10 Dec 2010 Downloads: 185
Not Supported Uses Plugins Template Edits Translations  

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.



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 -
HTML 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 -
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 -
PHP Code:
$today vbdate('Y-m-d'TIMENOWfalsefalse);

// ### 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 ($birthdaystruefalse);
}
else
{
    
$show['birthdays'] = false;
}

$birthdaysarray = array('birthdays' => $birthdays,
    
'show' => $show,
    );
vB_Template::preRegister('vbcms_widget_execphp_birthdays'$birthdaysarray); 
After install clear the CMS cache

Download

File Type: %1$s widget-birthdays 1.0.txt (3.2 KB, 190 downloads)

Screenshots

Click image for larger version
Name:	todays_birthdays_widget.jpg
Views:	2230
Size:	6.6 KB
ID:	124357  

Similar Mods

Mini Mods Number of Today's Birthdays on FORUMHOME Modification Graveyard

vblts.ru supports vBulletin®, 2022-2024