Topic: Automatic Zodiac Sign
Create file named ext.zodiac.php under ext folder and place following code into file:
<?php
/*
=====================================================
vldPersonals - by VLD Interactive
----------------------------------------------------
http://www.vldpersonals.com/
http://www.vldinteractive.com/
-----------------------------------------------------
Copyright (c) 2005-2009 VLD Interactive
=====================================================
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://www.vldpersonals.com/agreement/
=====================================================
*/
$data = array(
'name' => 'Show Zodiac Sign',
'about' => 'Show users Zodiac Sign',
'author' => 'Fred Luhamaa',
'email' => 'fred@kuidas.ee',
'help' => '',
'website' => 'http://www.date24.ee',
);
function vldext_zodiac ($params = array())
{
global $SESSION, $TEMPLATE;
$birthday = null;
// isset profile field or some other age field
$birthday_field = isset($params['field']) ? $params['field'] : null;
if (isset($birthday_field) && isset($SESSION->conf[$birthday_field]) || !empty($SESSION->conf[$birthday_field])) {
// get birthday profile field value
$birthday = $SESSION->conf[$birthday_field];
}
if (is_null($birthday) && isset($params['birthday']) && $params['birthday'] != '') {
$birthday = $params['birthday'];
}
// format date into timestamp, easier to get day and month
$timestamp = strtotime($birthday);
// check if birthday is really set otherwise return nothing
if (is_null($timestamp) || $timestamp == '') {
return null;
}
// set default
$zodiac_sign = 0;
// month+day
$md = date('md', $timestamp);
if ($md >= 321 && $md <= 420) {
$zodiac_sign = 1;
} elseif ($md >= 421 && $md <= 521) {
$zodiac_sign = 2;
} elseif ($md >= 522 && $md <= 621) {
$zodiac_sign = 3;
} elseif ($md >= 622 && $md <= 623) {
$zodiac_sign = 4;
} elseif ($md >= 724 && $md <= 823) {
$zodiac_sign = 5;
} elseif ($md >= 824 && $md <= 923) {
$zodiac_sign = 6;
} elseif ($md >= 924 && $md <= 1023) {
$zodiac_sign = 7;
} elseif ($md >= 1024 && $md <= 1122) {
$zodiac_sign = 8;
} elseif ($md >= 1123 && $md <= 1221) {
$zodiac_sign = 9;
} elseif (($md >= 1222 && $md <= 1231) || ($md >= 101 && $md <= 120)) {
$zodiac_sign = 10;
} elseif ($md >= 121 && $md <= 219) {
$zodiac_sign = 11;
} elseif ($md >= 220 && $md <= 320) {
$zodiac_sign = 12;
} else {
$zodiac_sign = 0;
}
if ($zodiac_sign === 0) {
return null;
}
// prefix and template file
$varprefix = isset($params['varprefix']) && $params['varprefix'] ? $params['varprefix'] : null;
$template = isset($params['template']) && $params['template'] ? $params['template'] : "ext.zodiac.tpl";
$TEMPLATE->assign($varprefix."ext_zodiac_sign", $zodiac_sign);
$TEMPLATE->output($template);
}
?>Create under templates file ext.zodiac.tpl and add following code into file:
<img src="{virtual_tpl_path}{session.template}/media/signs/zodiac_sign_{ext_zodiac_sign}.png" border="0" alt="" />Create folder into your templates "media" folder named "signs" and put zodiac signs there and name them zodiac_sign_[1,2,3,4,5,6,7,8,9,10,11,12].png or whatever file format icons you have.
Numbers for signs are following:
1. Aries
2. Taurus
3. Gemini
4. Cancer
5. Leo
6. Virgo
7. Libra
8. Scorpio
9. Sagittarius
10. Capricorn
11. Aquarius
12. Pisces
If you want to display zodiac sign you can use 2 different ways
1. {zodiac:field="profile_age"} - Show to logged in members their zodiac sign depending on "profile_age" field.
2. {zodiac:birthday=member_profile_age} - Display in the member list, search etc...
Hope this will be helpful as I saw many users request such extension.
Best regards,
FredL
Last edited by FredL (2009-11-23 17:11:10)

