kyrnel
12-19-2004, 10:00 PM
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: // get first and last post ids for this page (for big reply buttons)
Right before it place:// %%%%%%%%%%%%%%%%%%%%%%% Birthday Conditional Hack %%%%%%%%%%%%%%%%%%%%%%%%
$smonth = vbdate('n', TIMENOW, false, false);
$sday = vbdate('j', TIMENOW, false, false);
$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:
<if condition="$post['age']=='YES'">
I just made it put a small birthday cake image next to their name with this 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. :)]
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: // get first and last post ids for this page (for big reply buttons)
Right before it place:// %%%%%%%%%%%%%%%%%%%%%%% Birthday Conditional Hack %%%%%%%%%%%%%%%%%%%%%%%%
$smonth = vbdate('n', TIMENOW, false, false);
$sday = vbdate('j', TIMENOW, false, false);
$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:
<if condition="$post['age']=='YES'">
I just made it put a small birthday cake image next to their name with this 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. :)]