chelle40 Posted January 22, 2013 Posted January 22, 2013 Hi, Is there a way to make reviews anonymous. I am using oscommerce ver 2.3.1. We are a brand new company and have had 1 great review but need more. We've had people who have wanted to write reviews but they don't want their name shown. The only way people can write a review is if they log in and their name is automatically shown. Seeing as how we sell home brew products I can see how people wouldn't want their names public on the internet for this. Thank you, Shelli Quote
MrPhil Posted January 22, 2013 Posted January 22, 2013 This question has come up before. You could change $reviews['customers_name'] to 'Anonymous', or find some way to break apart the customers_name string into a first and last name, and initialize the last name: Shelli Catacci becomes Shelli C. . I think the latter way is better, as having people show up as "anonymous" (or completely unsigned) tends to encourage irresponsible posting. However, there's no foolproof way to take a name string and process it. An alternative might be to initialize everything: Shelli Catacci becomes S. C. . That way, if you gave the name as Catacci, Shelli it wouldn't reveal the last name, but would be C., S.. Just some thoughts... Quote
chelle40 Posted January 22, 2013 Author Posted January 22, 2013 Thank you for the responses. Phil, is there a way to make it a text field that forces a minimum of 2 chars? That way if they want to put their name they can but if they don't they can put initials or whatever? Thanks, Shelli Quote
MrPhil Posted January 24, 2013 Posted January 24, 2013 I suppose that with Javascript on the client side, and PHP code checking form input on the server side, you can force whatever minimum and maximum number of characters you want. Does the current code force at least one character for a name? That should be sufficient (as long as it's a letter, which is another check). It shouldn't be too hard to take a name string and collapse each run of two or more consecutive letters to just the initial letter. Ludwig von Beethoven becomes L v B -- is that adequate? You could add a period wherever letters are dropped: L. v. B. etc. Harry S Truman becomes H S T or H. S T. Somewhat riskier would be to take the last multiletter substring and reduce it to one letter: "Shelli Catacci" becomes "Shelli C.", but "Mao Zedong" becomes "Mao Z.", which is not what's desired ("M. Zedong"). Likewise, "Catacci, Shelli" becomes Catacci, S., unless you spot the comma and assume it's last name first. It gets complicated fast, which is why I would suggest just sticking with initials. Quote
chelle40 Posted January 25, 2013 Author Posted January 25, 2013 I found this php code but don't know exactly where it would go. Any suggestions? function getInitials($name){ //split name using spaces $words=explode(" ",$name); $inits=''; //loop through array extracting initial letters foreach($words as $word){ $inits.=strtoupper(substr($word,0,1)); } return $inits; } Thank you Shelli Quote
MrPhil Posted January 26, 2013 Posted January 26, 2013 It can go in any .php file that happens to be loaded on the page where you need to call it. Just stick it at the bottom just before ?> . Note that it will turn "Ludwig von Beethoven" into "LVB". OK? Quote
chelle40 Posted January 30, 2013 Author Posted January 30, 2013 Thanks again Phil, Sorry it has take me so long to reply. LVB is fine with me. When you say "in any .php file that happens to be loaded on the page where you need to call it" - how would I know which files I would need? Would it be the ones where in the oscommerce merchant --> Modules --> Boxes --> Reviews - would it be those I have marked under "Display in pages"? I opened up one of those files and added the code just before the last ?> And this is what it looks like (Well, the end). Is that right? <?php require(DIR_WS_INCLUDES . 'template_bottom.php'); require(DIR_WS_INCLUDES . 'application_bottom.php'); function getInitials($name){ //split name using spaces $words=explode(" ",$name); $inits=''; //loop through array extracting initial letters foreach($words as $word){ $inits.=strtoupper(substr($word,0,1)); } return $inits; } ?> Quote
MrPhil Posted January 30, 2013 Posted January 30, 2013 If you want this function in only one place, go ahead and stick it in the file (e.g., ..../product_review.php) that is used. If you want it used in multiple places, you'll have to put it in a file that is common to all the places. I'm unable to get to my copy of osC to look, but there ought to be some file commonly used. If <?php require(DIR_WS_INCLUDES . 'template_bottom.php'); require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> was all there was before, that's fine. Just be careful not to leave spaces or blank lines after the ?>. Remember, that only defines the function. Now you have to figure where to use it. Quote
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.
Note: Your post will require moderator approval before it will be visible.