1

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)

2

Re: Automatic Zodiac Sign

thank you for the extention! works perfectly!

3

Re: Automatic Zodiac Sign

Any demo so we can see it !!! Thanks

4

Re: Automatic Zodiac Sign

what is the code to Display in the member list, search etc...and showing members  zodiac sign depending on "their birth date? in what file i need to insert this code?  thanks

Sorry for my English...I really do

5

Re: Automatic Zodiac Sign

someone?

Sorry for my English...I really do

6

Re: Automatic Zodiac Sign

I think it is better FredL answer you question ...

Give the world the best you have, and the best will come to you.
Tutorials and Mods for VldPersonals  Add CometChat to your vldPersonals site

7

Re: Automatic Zodiac Sign

Is this a mistake (not the two $zodiac_sign = 11;)?
  } elseif ($md >= 121 && $md <= 219) {
    $zodiac_sign = 11;
  } elseif ($md >= 220 && $md <= 320) {
    $zodiac_sign = 11;

Should it be:
  } elseif ($md >= 121 && $md <= 219) {
    $zodiac_sign = 11;
  } elseif ($md >= 220 && $md <= 320) {
    $zodiac_sign = 12;

Last edited by idealists (2009-10-15 01:41:31)

8

Re: Automatic Zodiac Sign

Hi, I'm trying to follow this tutorial, but on the final step, in which file(s) do I have to put these pieces of codes? 

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...

Please help.

Last edited by dj24 (2009-11-21 13:11:54)

9

Re: Automatic Zodiac Sign

idealists wrote:

Is this a mistake (not the two $zodiac_sign = 11;)

Yeah, thx idealists for pointing that out, 12 should be there. Fixed it.

dj24 wrote:

Hi, I'm trying to follow this tutorial, but on the final step, in which file(s) do I have to put these

Put this code in the template where you want to display zodiac sign.

For example you want to show zodiac sign for logged in member in his "homepage" template.

{zodiac:field="profile_age"}

This will calculate zodiac sign from profile field called "age".

If you want to show zodiac sign in loops eg. "search results" you can add to results template into loop:

<!-- BEGIN search_profiles -->
/..... here some info about member .... /

Zodiac Sign: {zodiac:birthday=profile_field_age_value}
<!-- END search_profiles -->

Last edited by FredL (2009-11-23 17:09:34)

10

Re: Automatic Zodiac Sign

I got this to work great on Google Chrome and Firefox in the search results, but it doesn't show up in Internet explorer. I used {zodiac:birthday=profile_field_age_value}. Any idea why it wouldn't work in IE?

11

Re: Automatic Zodiac Sign

MudiO90NbvC wrote:

I got this to work great on Google Chrome and Firefox in the search results, but it doesn't show up in Internet explorer. I used {zodiac:birthday=profile_field_age_value}. Any idea why it wouldn't work in IE?

Clear cache and template cache.
If you got it to work in FF and Chrome, then problem can't be in extension, but its probably in template image HTML code.
How do you display image? Show template code, so we can debug this.

12

Re: Automatic Zodiac Sign

Hi, It's ok now. Internet Explorer didn't like me applying any styling to it. I had to shove it in between two <td></td> tags or it wouldn't show up. I wanted to apply a div class from the CSS I had made, but for some reason it wouldn't work. I don't know if I should have used some IE fix. I don't know a lot about CSS.

13

Re: Automatic Zodiac Sign

No matter what i do it won't show up in IE.

<!-- IF profile_field_age_name -->
    <dt>{lang:"core","userinfo_age"} :</dt>
    <dd>{profile_field_age_value_years}</dd>
<!-- ENDIF -->

Where should i add the code, and is any way to show the zodiac sign even you are not logged in.
Thx

14

Re: Automatic Zodiac Sign

reklamat wrote:

Where should i add the code, and is any way to show the zodiac sign even you are not logged in.
Thx

Use it like this:

<!-- IF profile_field_age_name -->
  <dt>{lang:"core","userinfo_age"}:</dt>
  <dd>{profile_field_age_value_years}&nbsp;{zodiac:birthday=profile_field_age_value}</dd>
<!-- ENDIF -->

15

Re: Automatic Zodiac Sign

I clear my template cache and is working fine. Thanks

16

Re: Automatic Zodiac Sign

For some reasons sign "Cancer" is not working.

17

Re: Automatic Zodiac Sign

I slightly modified the Zodiac extension published by FredL.
Purpose of my modification was a  possibility of viewing a title  such "Aries" or "Scorpio", when pointing the mouse arrow to according Zodiac icon.

For that I changed in ext.zodiac.php all numbers, associated with $zodiac_sign to appropriate Zodiac names.
Also I changed the names of icons from zodiac_sign_X.png to appropriate Zodiac names, such "Aries.png","Scorpio.png" etc., and made some changes in  ext.zodiac.tpl for viewing a title.

The "Ultimate edition" ;) of this two files is posted  below:

ext.zodiac.php:

<?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 = null;
  // month+day
  $md = date('md', $timestamp);

  if ($md >= 321 && $md <= 420) {
    $zodiac_sign = Aries;
  } elseif ($md >= 421 && $md <= 521) {
    $zodiac_sign = Taurus;
  } elseif ($md >= 522 && $md <= 621) {
    $zodiac_sign = Gemini;
  } elseif ($md >= 622 && $md <= 623) {
    $zodiac_sign = Cancer;
  } elseif ($md >= 724 && $md <= 823) {
    $zodiac_sign = Leo;
  } elseif ($md >= 824 && $md <= 923) {
    $zodiac_sign = Virgo;
  } elseif ($md >= 924 && $md <= 1023) {
    $zodiac_sign = Libra;
  } elseif ($md >= 1024 && $md <= 1122) {
    $zodiac_sign = Scorpio;
  } elseif ($md >= 1123 && $md <= 1221) {
    $zodiac_sign = Sagittarius;
  } elseif (($md >= 1222 && $md <= 1231) || ($md >= 101 && $md <= 120)) {
    $zodiac_sign = Capricorn;
  } elseif ($md >= 121 && $md <= 219) {
    $zodiac_sign = Aquarius;
  } elseif ($md >= 220 && $md <= 320) {
    $zodiac_sign =  Pisces;
  } else {
    $zodiac_sign = null;
  }
  if ($zodiac_sign === null) {
    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);
}

?>

ext.zodiac.tpl:

<P ALIGN=LEFT><img src="{virtual_tpl_path}{session.template}/media/signs/{ext_zodiac_sign}.png" border="0" TITLE="{ext_zodiac_sign}" /></P>

As for me the best way to use the Zodiac signs is to show it in members profiles near the "age" field.
For that I changed the profile field section of the file member_profile.tpl like below:

<!-- BEGIN profile_fields -->
    <dt> <H4> {field_name}: </H4> </dt>  
       <dd>
    <!-- IF field_value -->
     <!-- IF field_type == "checkbox" -->
    {break:field_value}
    <!-- ELSEIF field_type == "birthday" -->

        <H4> {field_value_years} </H4>   {zodiac:birthday=field_value}        

        <!-- ELSE -->

    <H4> {field_value}</H4>                    

            <!-- ENDIF -->
    <!-- ELSE -->
    <H4>{lang:"core","user_field_none"}</H4>
    <!-- ENDIF -->                            

    </dd>                            

<!-- END profile_fields -->

in this code the {zodiac:birthday=field_value} is responsible for Zodiac sign publishing.
(<H4> </H4> included by me is only for appearance)

Results you can see here:
http://img686.imageshack.us/img686/4628/dasha.jpg

Please pay attention that {zodiac:birthday=field_value} is working only when "month" field of profile is shown in English transcription (all questions to FredL and people who invent the commands "strtotime" and "date").

18

Re: Automatic Zodiac Sign

I want to know, is this showing the sign automatic, depending on birthday date, or you must set your sign in your profile?

19

Re: Automatic Zodiac Sign

Depending on birthday date.

20

Re: Automatic Zodiac Sign

Is it possible to make in Profilefield a zodiac without pictures?

Name: xxxx
I am: xxxxx
I seek: xxxx
Age: xxxx
Zodiac: Gemini
Country: xxxxx
City: xxxx

http://img188.imageshack.us/img188/3791/zodiace.jpg

Last edited by Holger (2010-01-19 20:45:24)

21

Re: Automatic Zodiac Sign

Holger wrote:

Is it possible to make in Profilefield a zodiac without pictures?
Name: xxxx
I am: xxxxx
I seek: xxxx
Age: xxxx
Zodiac: Gemini
Country: xxxxx
City: xxxx

Yes ...

Give the world the best you have, and the best will come to you.
Tutorials and Mods for VldPersonals  Add CometChat to your vldPersonals site

22

Re: Automatic Zodiac Sign

http://www.vldpersonals.com/forum/viewtopic.php?id=6407&p=1 this one im using in my site but cancer sign is not working.

Last edited by reklamat (2010-01-20 16:22:33)

23

Re: Automatic Zodiac Sign

yes but he will not have images only text smile

Give the world the best you have, and the best will come to you.
Tutorials and Mods for VldPersonals  Add CometChat to your vldPersonals site

24

Re: Automatic Zodiac Sign

FredL wrote:

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...

Ok, I've tried at many ways, but the second way did not work. Only the first way is working, but if I put it in "member_profile.tpl", it's showing the zodiac of the logged in user, of course.

Please help me.

25

Re: Automatic Zodiac Sign

fozzy wrote:

Please help me.

This is 100% working: {zodiac:birthday=field_value}
For more details see my post #17 above.
Month field in all  lang.core.php files must be in English.