Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Beta Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Birthday Conditional in Postbit Details »»
Birthday Conditional in Postbit
Version: 1.00, by kyrnel kyrnel is offline
Developer Last Online: Jun 2013 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 12-19-2004 Last Update: Never Installs: 3
Is in Beta Stage  
No support by the author.

I found a way to create a birthday conditional in the postbit template.
This will allow you to put an image of a birtday cake (or something else) next to a person's username in a thread when it is thier birthday.

I have to admit, my method is kind of a hack, but it works fine as far as I can tell.

WARNING: This hack will hijack an existing post array value ($post[age]). If you display age on your forum's postbit, this hack will break that functionality.
I am open to suggestions on how to do this another way.

NOTE: I only created the code to make this work in Linear Mode. If someone wants to help make this work in Hybrid and Threaded mode, I am open to suggestions.

In showthread.php:

Find:
PHP Code:
        // get first and last post ids for this page (for big reply buttons) 
Right before it place:
PHP Code:
// %%%%%%%%%%%%%%%%%%%%%%% Birthday Conditional Hack %%%%%%%%%%%%%%%%%%%%%%%%

        
$smonth vbdate('n'TIMENOWfalsefalse);
        
$sday vbdate('j'TIMENOWfalsefalse);
        
$sdate explode('-'$post['birthday']);
        
        if (
$smonth == $sdate[0] AND $sday == $sdate[1])
        {
            
$post['age'] = 'YES';
        }
        else
        {
            
$post['age'] = 'NO';
        }
// %%%%%%%%%%%%%%%%%%%% End Birthday Conditional Hack %%%%%%%%%%%%%%%%%%%%%% 
Now in your postbit or postbit_legacy template, you can use the conditional:
HTML Code:
<if condition="$post['age']=='YES'">
I just made it put a small birthday cake image next to their name with this code:
HTML Code:
<if condition="$post['age']=='YES'"><img src="$stylevar[imgdir_misc]/birthday_small.gif" alt="IT'S MY BIRTHDAY!!"></if>
Below is a screencap..

[EDIT - You'll notice in the screen cap that Age is displayed as 'YES' or 'NO'. You will need to manually disable the display of age in the template since it was hijacked for another purpose. ]

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 12-19-2004, 11:33 PM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just use a different name....

Ie, AGEDISPLAY, instead of AGE.

PHP Code:
        if ($smonth == $sdate[0] AND $sday == $sdate[1]) 
        { 
            
$post['agedisplay'] = 'YES'
        } 
        else 
        { 
            
$post['agedisplay'] = 'NO'
        } 
Reply With Quote
  #3  
Old 12-20-2004, 06:57 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Taking the idea furthur, i have sucessfully gotten it working by adding a single line to adminfunctions_template.php, which adds the ability to use substr in templates.

Add to includes/adminfunctions_template.php (around line 1550, after
PHP Code:
            'is_member_of',          // function to check if $user is member of $usergroupid 
PHP Code:
            'substr',        // substring function to compare parts of strings 
Add to phpinclude_start
PHP Code:
$birthdaytoday vbdate('m-d-Y'TIMENOWfalsefalse); 
Add to the location that you want the image to appear in the postbit,

Code:
 <if condition="substr($post['birthday'], 0, 5) == substr($GLOBALS['todaysdateforbirthdays'], 0, 5)"><img class="inlineimg" src="$stylevar[imgdir_misc]/birthday_small.gif" border="0" alt="$post[username]'s birthday is today!" /></if>
I think its a nicer method, because it allows you to update everything without the hassle of having to hack each individual file. It is necessary to add substr to the allowed functions list, though.

Sorry if i should have made a new thread
Reply With Quote
  #4  
Old 12-20-2004, 11:09 AM
kyrnel's Avatar
kyrnel kyrnel is offline
 
Join Date: Nov 2001
Location: Houston, TX
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, this what I expected to happen.

There have been numerous requests for this conditional for quite a while and I figured I would have to come out with a bad solution in order to inspire someone who knoew what they were doing to come out with a good solution. LOL

But, I suppose that if the solution already requires modification to PHP files, that it should probably be easier to use in the templates. The substr() function makes sense to me, but it may be difficult for other members to implement.

I didn't know that you could just add an element to an array by simply declaring a value for it.
I tried using just some variable name I made up, but that didnt work, so I figured that I had to use an existing value.

I think the simpler the conditional, the better.

Would it work like this?
Code:
if ($smonth == $sdate[0] AND $sday == $sdate[1]) 
        { 
            $post['agedisplay'] = true; 
        } 
        else 
        { 
            $post['agedisplay'] = false; 
        }
Because then the conditional would just be <if condition="$post['agedisplay']">, right?
Reply With Quote
  #5  
Old 12-21-2004, 05:25 AM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, that is correct. You can just add another element to the array just by referencing it.

Your method will work, perfectly, i might add. However, it requires you modify a major function every time you upgrade.

With the method i wrote above, its less taxing, imo, to add a single allowance to the adminfunctions_template.php file, as it isnt necessary to re-add after an upgrade until you modify the postbit template again.

It is a shame that you need to add a function to the allow list, because there just wasnt enough allowed functions to work with to compare the strings. The $post['birthday'] field is MM-DD-YYYY (01-10-1980) of birth, whereas birthdaytoday is MM-DD-YYYY (01-10-2004), so you have to chop the end off. (You could reduce birthdaytoday to not have the year, but the compare still would be false without substr).
Reply With Quote
  #6  
Old 12-21-2004, 12:02 PM
kyrnel's Avatar
kyrnel kyrnel is offline
 
Join Date: Nov 2001
Location: Houston, TX
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That makes sense. So I guess it is a decision between a complex conditional or maintaining a modified showthread.php file.

My showthread.php was already modded before this, so I know which way I will go. But I think this could be written up both ways to allow people to decide which one they want to use. Do you think we should release these as two separate hacks or just combine them? If separate, then I will link to yours as an alternate method.
Reply With Quote
  #7  
Old 12-21-2004, 09:38 PM
merk merk is offline
 
Join Date: Nov 2001
Location: Canberra, Australia
Posts: 601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It doesnt bother me

Hopefully code will be added to construct_postbit() to work this out.

One hack is probably easier.
Reply With Quote
  #8  
Old 12-26-2004, 08:31 PM
That Rob Guy That Rob Guy is offline
 
Join Date: Dec 2004
Location: Bossier City, LA
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice screenshot from mx6.com :-)

Great hack

/me installs hack.
Reply With Quote
  #9  
Old 01-12-2005, 04:54 AM
BeatificFaith's Avatar
BeatificFaith BeatificFaith is offline
 
Join Date: May 2004
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does this hack work now with the age in the postbit? I'm asking because of the modified replies.

Thanks


Quote:
WARNING: This hack will hijack an existing post array value ($post[age]). If you display age on your forum's postbit, this hack will break that functionality.
Reply With Quote
  #10  
Old 01-12-2005, 12:52 PM
kyrnel's Avatar
kyrnel kyrnel is offline
 
Join Date: Nov 2001
Location: Houston, TX
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tia
Does this hack work now with the age in the postbit? I'm asking because of the modified replies.

Thanks
Yep, Just be sure to use 'agedisplay' as the variable name instead of 'age'. That way it won't interfere with the Age in postbit. I will go ahead and write this up as a hack.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 12:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04555 seconds
  • Memory Usage 2,324KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (2)bbcode_html
  • (6)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete