форум vBSupport.ru > vBulletin > vBulletin 4.0.x-4.1.х > Хаки, моды и скрипты 4.0.x-4.1.х
  • »
VBsupport перешел с домена .ORG на родной .RU Ура! Пожалуйста, обновите свои закладки - VBsupport.ru
 
 
 
 
SMak044
Эксперт
 
SMak044's Avatar
Default Widget - Today's Birthdays
0

Widget - Today's Birthdays
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

Источник
Attached Thumbnails
todays_birthdays_widget.jpg  
Attached Files
File Type: txt widget-birthdays 1.0.txt (3.2 KB, 5 views)
Bot
Yandex Bot Yandex Bot is online now
 
Join Date: 05.05.2005
Реклама на форуме А что у нас тут интересного? =)
 
 
alsy
Продвинутый
Default
2

На 4.2 почему то не заработал

alsy добавил 05.12.2012 в 16:51
Установка:
Создание нового шаблона

Стили и шаблоны - Управление стилями - выбираем вами используемый шаблон - Добавить новый шаблон
Заголовок - vbcms_widget_execphp_birthdays
Шаблон -
Код HTML:
PHP 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> 
Создание нового модуля
Продукты и модули - Добавить новый модуль
Местоположение модуля - cache_templates
Заголовок - Cache template for Today's Birthdays Widget

PHP Code:
if (THIS_SCRIPT == 'vbcms')
{
    
$cache[] = 'forumhome_birthdaybit';

Модуль включен - Да
Создание нового виджета
vBulletin CMS -Виджеты - Создать новый виджет
Тип виджета - Прямое выполнение PHP кода
Заголовок - С днем рожденья!
Сохранить

Настройка виджета
vBulletin CMS -Виджеты - С днем рожденья! - Настройка
Название шаблона - vbcms_widget_execphp_birthdays

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); 
После установки очистить кэш CMS

Last edited by alsy : 12-05-2012 at 06:51 PM. Reason: Добавлено сообщение
 
 
anelly
Эксперт
 
anelly's Avatar
Default
0

alsy, это уже доработка для 4.2? может, в раздел для 4.2 стоило написать? Хороший виджет. А с ютубом виджет в 4.2 у тебя работает?была бы очень признательна за решение - уже замучалась...
 
 
alsy
Продвинутый
Default
1

anelly,
Нет это перевод
Сама никак не разберусь
Пустой шаблон виджета php выглядит на 4.2 так:
PHP Code:
<div class="cms_widget">
<
div class="block">
<
div class="cms_widget_header widget_header">
    <
h3><img src="{vb:stylevar imgdir_siteicons}/php.png" alt="" /> {vb:raw title}</h3>
</
div>
<
div class="cms_widget_content widget_content">
{
vb:raw output}
</
div>
</
div>
</
div
Я думаю что шаблон vbcms_widget_execphp_birthdays
должен выглядеть так:
PHP Code:
<vb:if condition="$show['birthdays']"
<
div class="cms_widget"
    <
div class="block"
        <
div class="cms_widget_header 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> 
но все равно не работает
Quote:
Originally Posted by anelly View Post
А с ютубом виджет в 4.2 у тебя работает?
Да
Может кто поможет?
 

Tags
birthday, cms, today, widget


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT +4. The time now is 09:10 PM.


Powered by vBulletin® Version 3.6.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Loading...