Birthday in News?

Started by Jerri Blank, March 06, 2008, 01:11:09 AM

Previous topic - Next topic

Jerri Blank

Guys:

Is it possible to write a mod that would display "Happy Birthday, (membername)" in the news at the top of the page, with the username of those with birthdays inserted automatically?

Thanks,

jb

lordtron

Yeah I think that would be possible to have done. I don't think it would require much cause you would just have to write code that would read the Calendar and when it hits the day of the birthday then send a line of code into the news database to be read and once the day is over then have it be deleted.

VainSoftGames.com - New Design To Gaming

JustJa

Quote from: lordtron on March 06, 2008, 07:39:11 AM
Yeah I think that would be possible to have done. I don't think it would require much cause you would just have to write code that would read the Calendar and when it hits the day of the birthday then send a line of code into the news database to be read and once the day is over then have it be deleted.
Could you or someone else write this piece of code to us "dummies" plesase?
It would be much apreciated!

ccbtimewiz

Try using this...

if( $context['member']['today_is_birthday'] ) { echo 'Happy birthday'.$context['member']['name'].''; }

Jerri Blank

Thanks, ccbtimewiz.  Any suggestions on where that would go?

ccbtimewiz

#5
Erm... in the index.template.php file.

Such as:

Find:
<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>

Do this instead:
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">';

if( $context['member']['today_is_birthday'] )
echo '<span class="smalltext"><b>Happy birthday, '.$context['member']['name'].'!</b></span>';
else
echo '<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>';

echo '
</td>';



JustJa

Thank you...
I might have done something wrong though when I used the code.
I was getting a Parse error:

syntax error, unexpected T_STRING, expecting ',' or ';' in .../index.template.php on line 333
do you have any clue?

ccbtimewiz

Can you show me your template? Can you attach it?

[SiNaN]

Maybe this ccbtimewiz:

Find:
<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>

Do this instead:
';
if( $context['member']['today_is_birthday'] )
echo '<span class="smalltext"><b>Happy birthday, '.$context['member']['name'].'!</b></span>';
elseif
echo '<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>';

echo '
Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz

Ah... the missing to end the of the other statement. ^^;

Jerri Blank

#10
Okay, I got a little confused, but here's what I have now:

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">';
';
if( $context['member']['today_is_birthday'] )
echo '<span class="smalltext"><b>Happy birthday, '.$context['member']['name'].'!</b></span>';
elseif
echo '<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>';
echo '
</td>';


I don't get an error, but I also don't see the birthday greeting in the news.  I've given myself a birthday today, but it's not there.

Thanks!

ccbtimewiz

#11
Quote from: Jerri Blank on July 24, 2008, 02:04:32 PM
Okay, I got a little confused, but here's what I have now:

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">';
';
if( $context['member']['today_is_birthday'] )
echo '<span class="smalltext"><b>Happy birthday, '.$context['member']['name'].'!</b></span>';
else
echo '<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>';
echo '
</td>';


I don't get an error, but I also don't see the birthday greeting in the news.  I've given myself a birthday today, but it's not there.

Thanks!

Are you quite sure it didn't come with a parse error? Because that should be like:

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">';

if( $context['member']['today_is_birthday'] )
  echo '<span class="smalltext"><b>Happy birthday, '.$context['member']['name'].'!</b></span>';
elseif
echo '<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>';
echo '
</td>';

MissyNL

This is a great request... when it's sorted out, i will implement it to :D
Sorry for my poor English, but i think it's probably better then your Dutch :)

Jerri Blank

Still not working, cc.  I have a news item in there now - do I need to disable it or change my news settings in some way to get this to work?

And is anyone besides me seeing a floating photo of a stuffed animal while viewing this thread?

thanks,

jb

[SiNaN]

That animal is the Llama thing, see this topic:

http://www.simplemachines.org/community/index.php?topic=251474.0;topicseen

And why you cannot see is, it just appears when its the birthday of the user viewing the board. I mean, if today is my birthday, then when I see your boardindex, it says me "happy birthday".

If you want to display all the users you need to use the birthday list in the context array I guess. Ccbtimewiz could help you I hope.
Former SMF Core Developer | My Mods | SimplePortal

Jerri Blank

Hmmm.  I set myself as the birthday girl by changing my DOB in my profile and still didn't see it.

Ah, well - no worries; I have a block that display's this month's birthdays.


jb

lindaf

yeah... this is a great idea!!!  I would be interested in having a mod like this too! That shows everyone the birthday msg.

JustJa

what happens to me is this:
I have
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">

<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>


</td>';
echo '



Than when I change to:
// Show a random news item? (or you could pick one from news_lines...)
   if (!empty($settings['enable_news']))
      echo '
            <td width="90%" class="titlebg2">';

      if( $context['member']['today_is_birthday'] )
         echo '<span class="smalltext"><b>Happy birthday, '.$context['member']['name'].'!</b></span>';
      elseif
         echo '<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>';

      echo '
            </td>';
echo '


                     
         I get:

Parse error: syntax error, unexpected T_ECHO, expecting '(' in /home2/xxx/public_html/forum/Themes/novothema/index.template.php on line 350
      
            

[SiNaN]

Find in codes:

      elseif

Replace:

      else

ccbtimewiz, do not code when you are sleepy, just SleePy can do that. :P
Former SMF Core Developer | My Mods | SimplePortal

ccbtimewiz

Quote from: [SiNaN] on August 01, 2008, 01:46:09 PM
Find in codes:

      elseif

Replace:

      else

ccbtimewiz, do not code when you are sleepy, just SleePy can do that. :P

Not my code. Mine has "else". If you bothered to look, that's your code from here. ;)

Advertisement: