To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic

  • *Total Posts: 16404
  • *Total Topics: 2518
  • *Online Today: 10
  • *Most Online: 292
(12. Nov 2016, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 2
  • *Total: 2

  • *Yahoo!
  • *Google

Upcoming birthdays

Started by DirtRider, 24. Nov 2008, 19:42:22

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

Go Down

digiscrap

#15
26. Nov 2008, 12:56:24
Quote from: feline on 25. Nov 2008, 20:55:48
Ahh .. now I understand what you mean  ::)
You will use the align as defined for the block Title ...

Fel

Ohw... now I see. The align is only for the block title  :D Didn't know that  :-[ The 'align switch' was present in the original script, so I thought is was some standard for PortaMx. But now I know I mis understand the function.

I don't know if this 'align switch' is very useful. No other Blocks are using this (I noticed that this morning), so would it be unnecessary for this script I think (and I removed it). All default blocks are aligned left.

Thanks again for your support!!

Hereby the final script:

Code Select

// Birthdays: list birthdays block script
// Original script from: July 01, 2008 / Tim Antley / www.BayouMX.com
// Scrip upgraded by: Feline (PortaMx), digiscrap (digiscrap.nl)
// - updated 07/19/08: Highlights a birthday on current date
// - updated 11/24/08: SMF2/PortaMx block script
// - updated 11/26/08: Display date and links to calendar month
// Script for retrieving upcoming member birthdays for current month.
// Calculates age and links to profile by member's name.

$current_date   = getdate();
$month_number   = sprintf("%02d", $current_date['mon']);

$justify      = 'left';   // Valid options: 'left', 'center', or 'right'
$limit         = 0;      // Integer value for length of list

if(!empty($_GET['justify']))   $justify            = $_GET['justify'];
if(!empty($_GET['limit']))      $limit               = $_GET['limit'];
if(!empty($_GET['month']))      $month_number         = $_GET['month'];
if(!empty($_GET['day']))      $current_date['mday']   = $_GET['day'];

if($limit == 0)               $count               = -1;

global $smcFunc, $scripturl;

$query = $smcFunc['db_query']('', '
      SELECT id_member, member_name, birthdate
      FROM {db_prefix}members
      WHERE birthdate LIKE {string:likestr}     
      AND birthdate NOT LIKE {string:notlikestr}
      ORDER BY birthdate ASC',
   array(
      'likestr' => '%-%'. $month_number .'%-%',
      'notlikestr' => '0001-01-01',
   )
);

if($smcFunc['db_num_rows']($query) == 0)
   echo '<div class="smalltext"><b>No birthday\'s this month</b></div>';
else
{
while(($row = $smcFunc['db_fetch_assoc']($query)) && ($count < $limit))
{
   if($limit != 0) $count++;
   
   $dob_year   = strtok($row['birthdate'], '-');
   $dob_month   = strtok('-');
   $dob_day   = strtok('-');
   $age      = sprintf("%2d", ($current_date['year'] - $dob_year));

   if($current_date['mday'] <= $dob_day)
   {
      if($current_date['mday'] == $dob_day)
      {
         $class   = 'highlight';
      }
      else
      {
         $class   = '';
      }
     
echo '
<div class="smalltext" align="left"><span class="'.$class.'">
  <span class="'.$class.'"><a href="' . $scripturl . '?action=calendar;year=' . $current_date['year'] .';month=' . $current_date['mon'] . '">' .$dob_day.'-'.$dob_month.'<a/>       <a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['member_name'] . '</a>   ('.$age.')
   </span>
</div>';
   }

}
$smcFunc['db_free_result']($query);
}
Digiscrap Digitaal scrappen | Digiscrap Fotoservice

SMF2.0.5 + PortaMx v1.45
Dutch translation PortaMx1.45

DirtRider

#16
26. Nov 2008, 13:22:40
Well done with the mod on this code I like it  ;)
"The real question is not whether machines think but whether men do. "


afrosheen

#17
04. Jan 2011, 20:51:34
Hmm I've had this issue on some other tries of putting code in a block but end of getting a blank block.

Just to make sure I'm not missing something here's what I did, went to block manager, created a new block, I choose PHP in this instance.  I get the same result using Script also still blank.  I make sure it's visible and is enabled but I still get blank block.  Any suggestions?

SS attached.

[attachment deleted by admin]

feline

#18
04. Jan 2011, 20:56:52
What you have coded inside the PHP block?

el
Many are stubborn in relation to the path, a few in relation to the target.

afrosheen

#19
04. Jan 2011, 21:02:32
I pasted digiscrap final script from his code box that's like 3 postings above this one.

feline

#20
04. Jan 2011, 21:10:29
I have not tested that, but I think this works.
You are sure that you have the code copied completely and correct?

Fel
Many are stubborn in relation to the path, a few in relation to the target.

afrosheen

#21
04. Jan 2011, 21:15:20
I hope so LOL, I hit the Select text it highlights all the code, right click it Copy and then paste into my PHP block.  Sounds simple enough (feel like a super noob)  ;D, granite it doesn't have the nice formatted layout as in digiscrap code block, does that make a difference?

Others have replied that the code works.  I've had the same issue with calendar code that you updated and get the same blank block.

afrosheen

#22
04. Jan 2011, 21:43:19
Ah hah!  I fixed up most of the formatting and seems to resolved it nicely!

Any tricks to getting a good copy and paste?  As it seems to be pasting everything on 1 line in the porta blocks, my experience is in coldfusion and the commenting in PHP is different so I'd imagine the // comments were commenting out the whole code script.

Anyway this script is working now, any tricks on the copy/paste would help!  8)

feline

#23
04. Jan 2011, 21:52:13
Here es a other script that show the birthdays of the current month.
Use this only with SMF 2.0 RC4 ...

PHP block code:
Code Select

global $smcFunc, $scripturl, $sourcedir, $txt;

include_once($sourcedir .'/Subs-Calendar.php');
$month = (int) strftime('%m', forum_time());
$year = (int) strftime('%Y', forum_time());

$start_data = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
if($month == 12)
{
$month = 1;
$year++;
}
else
$month++;
$end_data = date('Y-m-d', mktime(0, 0, 0, $month, 0, $year));

$calbirthdays = getBirthdayRange($start_data, $end_data);
ksort($calbirthdays);

foreach($calbirthdays as $cdate => $data)
{
list($cdt['year'], $cdt['month'], $cdt['day']) = explode('-', $cdate);
foreach($data as $vals)
echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .': <a href="'. $scripturl .'?action=profile;u='. $vals['id'] .'">'. $vals['name'] .(!empty($vals['age']) ? '('. $vals['age'] .')' : '') .'</a><br />';
}


Looks like the attached image ..

Fel

[attachment deleted by admin]
Many are stubborn in relation to the path, a few in relation to the target.

afrosheen

#24
04. Jan 2011, 22:05:42
Thanks for the help fixing to upgrade in a few hours!

What's the trick on the copy and paste to keep it all going on 1 line when pasting the code?

b4pjoe

#25
05. Jan 2011, 01:02:58
Quote from: afrosheen on 04. Jan 2011, 22:05:42
Thanks for the help fixing to upgrade in a few hours!

What's the trick on the copy and paste to keep it all going on 1 line when pasting the code?


I wish I knew that answer too. It happens sometimes and sometimes it doesn't. I've had it happen here at this site, SMF's site, and my site and I've had it work properly at all 3 sites too. I just tried it copying directly from the post above into a PortaMx PHP block and it worked fine for me this time.

feline

#26
05. Jan 2011, 09:47:20
If the copy/paste not work properly this is often a browser problem or char set mistake.
We use utf-8 here and if you have iso set for your browser, this can get complications.
Best way ..
move the mouse to the first position in the code block, hold down the left mouse key and move the mouse down until all code is marked. Then take a right click, select copy from drop down menu.

Fel
Many are stubborn in relation to the path, a few in relation to the target.

kev

#27
22. Aug 2011, 11:26:46
Quote from: feline on 04. Jan 2011, 21:52:13
Here es a other script that show the birthdays of the current month.
Use this only with SMF 2.0 RC4 ...

PHP block code:
Code Select

global $smcFunc, $scripturl, $sourcedir, $txt;

include_once($sourcedir .'/Subs-Calendar.php');
$month = (int) strftime('%m', forum_time());
$year = (int) strftime('%Y', forum_time());

$start_data = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
if($month == 12)
{
$month = 1;
$year++;
}
else
$month++;
$end_data = date('Y-m-d', mktime(0, 0, 0, $month, 0, $year));

$calbirthdays = getBirthdayRange($start_data, $end_data);
ksort($calbirthdays);

foreach($calbirthdays as $cdate => $data)
{
list($cdt['year'], $cdt['month'], $cdt['day']) = explode('-', $cdate);
foreach($data as $vals)
echo $smcFunc['substr']($txt['months'][intval($cdt['month'])], 0, 3) .' '. $cdt['day'] .': <a href="'. $scripturl .'?action=profile;u='. $vals['id'] .'">'. $vals['name'] .(!empty($vals['age']) ? '('. $vals['age'] .')' : '') .'</a><br />';
}


Looks like the attached image ..

Fel


Hi will this code work for SMF Gold ? thank you

feline

#28
22. Aug 2011, 13:47:26
I think yes .. simple try it  ;)
Many are stubborn in relation to the path, a few in relation to the target.

star45

#29
28. Dec 2011, 12:55:02
I have improved the question and a lot of columnames .. that's all.

Go Up