1

I'm totally stuck in this situation, can't find any solution, please help!

i have content profile date field "date of birth" (y-m-d) and node "horoscope" with multiple value date field (m-d). When new user registers his date of birth I need to auto-reference to the horoscope node with same date. Year is not important in that case.

For example:

I have "horoscope" nodes: (title - dates)

Horoscope A - 01.23, 03.11, 05.02 Horoscope B - 02.14, 07.01 Horoscope C - 11.11 Horoscope D - 02.10, 03.02, 05.07, 09.14 After new user registers his account with date of birth: 1977.07.01, I need "horoscope_reference" field to automatically assign him "Horoscope B" or if entered date of birth: 1234.03.02, "horoscope_reference" should be assigned to "Horoscope D" and so on...

any suggestions please? (drupal 7)

Thank You..

  • That sounds like you need to create a module which adds a field entry on node save – frazras Sep 9 '12 at 13:01
0

Use the computed field module for this. This lets you add your own conversion logic into the field (using PHP) that will be processed on entry. So download and enable the module, then add a field for your horoscope, then in the settings field, you want to add your PHP logic, ex (roughly):

$date = new DateTime($entity->field_profile_dob[LANGUAGE_NONE][0]['value']);
$month = $date->format('m');
$day = $date->format('d');
if (($month = 1) && ($day < 21)) {
    $answer = "some sign";
} else if .. etc.

That will take some time to write that logic. You might be better off putting this in a module then leaving it in the settings. There are dozens of examples in the documentation that should help you get started on this.

  • thanx a lot, I did it already by creating my own module. I have horoscope signs as nodes so logic is much simpler, i just had to find signs by its date field... But your suggestion is appreciated... Thank You. – raganara Sep 12 '12 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.