jdmcelica01 Posted May 14, 2009 Share Posted May 14, 2009 I am in the process of finishing a review website and am looking for some php code for the fivestar voting target. I have two content types which include Review and Location. In the Location content type I am using the node comments module. With this module, the core drupal comments are replaced with the review content type. When a user decides to review a location, they select the "add a new review" link on that particular location node which opens the review content type. The Review content type includes a single CCK field which includes each day of the week and another field which contains a single CCK fivestar voting widget. When filling out a review, I would like the person to select the day of the week they visited a particular location as well as a rating for that particular day. After submitting the review, I would like the vote to be saved to the parent node with a tag corresponding to the day of the week which was selected by the user. In CCK fivestar there is a voting target box which allows you to input custom php code to designate where the vote is saved. I was thinking I add 7 "if" statements in this box, one for each day of the week. Something similar to this: If field_dayofweek='sunday' then save to parent node id with sunday tag or voting axis If field_dayofweek='monday' then save to parent node id with monday tag or voting axis If field_dayofweek='tuesday' then save to parent node id with tuesday tag or voting axis etc... I believe that something similar to this would work, but am having difficulty in determining what the correct syntax would be. If you have any experience with php and drupal I would really appreciate some assistance. This is the last feature that needs to be implemented before the site goes live. Any assistance at all would be very helpful. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/158146-can-someone-please-help-me-write-php-code-for-drupal-6/ Share on other sites More sharing options...
Hybride Posted May 19, 2009 Share Posted May 19, 2009 Case statements work easier for multiple if/else statements. You can try something like this: switch($field_dayofweek) { case "sunday": // save to parent node with sunday break; case "monday": // save to parent node with monday break; case "tuesday": // save to parent node with tuesday break; ... default: // whatever you want default statement to be break; } Quote Link to comment https://forums.phpfreaks.com/topic/158146-can-someone-please-help-me-write-php-code-for-drupal-6/#findComment-837393 Share on other sites More sharing options...
jdmcelica01 Posted May 20, 2009 Author Share Posted May 20, 2009 Thank you for your response to my question. After looking at the code you posted, I was wondering if you have any insight one what I should replace "// save to parent node with..."? Is it just a return command? Something similar to this: <?php switch($field_dayofweek) { case "sunday": return parent node id with sunday tag break; case "monday": return parent node id with monday tag break; case "tuesday": return parent node id with tuesday tag break; ... default: // whatever you want default statement to be break; } ?> Thank you again for your assistance. Quote Link to comment https://forums.phpfreaks.com/topic/158146-can-someone-please-help-me-write-php-code-for-drupal-6/#findComment-838221 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.