lindsayanng Posted August 9, 2010 Posted August 9, 2010 My client pointed out that MOST people probably don't want their first and last name on reviews written on my site. I am not overly familiar with mysql and the osc database in that way, so i was wondering if anyone has managed to only use the first name.. here is my code as I have it now: $reviews_query = tep_db_query("select r.reviews_id, rd.reviews_text, r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and rd.reviews_id = r.reviews_id and rd.languages_id = '" . $languages_id . "' order by r.reviews_id DESC"); <div id="writtenReviews"><?php echo '<span class="bold-text"><b>Submited By:</b></span><span class="highlight-text"> ' . $reviews_values['customers_name'] . ' </span> <span class="smallText">on ' . $date_added . '</span><br><span class="normalText">' . htmlspecialchars($reviews_values['reviews_text']) . '</span><br>' . sprintf(tep_image(DIR_WS_IMAGES . 'stars_' . $reviews_values['reviews_rating'] . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $reviews_values['reviews_rating']))) ?> A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
lindsayanng Posted August 9, 2010 Author Posted August 9, 2010 Hmm i am kinda on a role here!! Got this to work.. to remove the last name on the reviews add this to your queries: $name_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'"); $name = tep_db_fetch_array($name_query); and then find where it searches for customer_name and replace with customers_firstname A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
lindsayanng Posted August 9, 2010 Author Posted August 9, 2010 So the other thing I am currently working on in the reviews panel is to trunacte the number or characters it shows on the productpage.. Any thoughts on how to take this code: <div id="writtenReviews"><?php echo '<span class="bold-text"><b>Submited By:</b></span><span class="highlight-text"> ' . $name['customers_firstname'] . ' </span> <span class="smallText">on ' . $date_added . '</span><br><span class="normalText">' . htmlspecialchars($reviews_values['reviews_text']) . '</span><br>' . sprintf(tep_image(DIR_WS_IMAGES . 'stars_' . $reviews_values['reviews_rating'] . '.gif', sprintf(BOX_REVIEWS_TEXT_OF_5_STARS, $reviews_values['reviews_rating']))) ?> </div></div> and make it so it only shows the first 200 character of the review it pulls with a link to the rest on the product_reviews.php page?? A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
npn2531 Posted August 9, 2010 Posted August 9, 2010 On reviews.php look for this query near the top: $reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 325) as reviews_text, r.reviews_rating, r.date_added, p.products_id, pd.products_name, p.products_image, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = r.products_id and r.reviews_id = rd.reviews_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and rd.languages_id = '" . (int)$languages_id . "' order by r.reviews_id DESC"; $reviews_split = new splitPageResults($reviews_query_raw, MAX_DISPLAY_NEW_REVIEWS); Note the 325 in, - left(rd.reviews_text, 325) as reviews_text-, that will truncate the reviews text at 325 characters. It should work on any page you put that query. Also lower down on reviews.php you should have this code, which displays the reviewers name, review text and rating: <a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $reviews['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '"><span class="review_subtitle">' . $reviews['products_name'] . '</span></a> ' . sprintf(TEXT_REVIEW_BY, tep_output_string_protected($reviews['customers_name'])) . ''; ?> and this <?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_INFO, 'products_id=' . $reviews['products_id'] . '&reviews_id=' . $reviews['reviews_id']) . '">' . tep_image(DIR_WS_IMAGES . $reviews['products_image'], $reviews['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?> <br><?php echo tep_draw_separator('pixel_trans.gif', SMALL_IMAGE_WIDTH + 10, '10'); ?></span> <?php echo tep_break_string(tep_output_string_protected($reviews['reviews_text']), 60, '-<br>') . ((strlen($reviews['reviews_text']) >= 100) ? '....' : '') . '<br><br><i>' . sprintf(TEXT_REVIEW_RATING, tep_image(DIR_WS_IMAGES . 'stars_' . $reviews['reviews_rating'] . '.gif', sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])), sprintf(TEXT_OF_5_STARS, $reviews['reviews_rating'])) . '</i>'; ?> That will also give you link to the entire review on product_reviews_info.php, and '....' will get put and the end of the text. The only glitch is that it will break in the middle of a word. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120
lindsayanng Posted August 10, 2010 Author Posted August 10, 2010 George, I tried What you suggested but it did not work.. First i added your character truncator to the query - when I did that I lost the entire reviews text.. Also, i was confused with what you were trying to tell me to do with your second and third snippet of code.. This is the code that displays the review text on the page <span class="normalText">' . htmlspecialchars($reviews_values['reviews_text']) . '</span And this is my query $reviews_query = tep_db_query("select r.reviews_id, left(rd.reviews_text, 15), r.reviews_rating, r.date_added, r.customers_name from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and rd.reviews_id = r.reviews_id and rd.languages_id = '" . $languages_id . "' order by r.reviews_id DESC"); A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
lindsayanng Posted August 10, 2010 Author Posted August 10, 2010 I just tried this (something i found on the net) and it didn't work either <?php // Original PHP code by Chirp Internet: www.chirp.com.au // Please acknowledge use of this code by including this header. function myTruncate($string, $limit, $break=".", $pad="...") { // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; // is $break present between $limit and the end of the string? if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } return $string; } //EOF ?> <?php $shortdesc = myTruncate($reviews_values['reviews_text'], 2); echo "<p>$shortdesc</p>"; ?> I am going to guess that it doesnt like my $reviews_values['reviews_text'] variable.. A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
npn2531 Posted August 10, 2010 Posted August 10, 2010 Those snippets are stock OSCommerce code from reviews.php, minus the tables. Standard OSCommerce programming will truncate the reviews. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120
lindsayanng Posted August 10, 2010 Author Posted August 10, 2010 Ok i got a working script now function truncate_text($text, $nbrChar, $append='...') { if(strlen($text) > $nbrChar) { $text = substr($text, 0, $nbrChar); $text .= $append; } return $text; } <span class="normalText">' . truncate_text($reviews_values['reviews_text']) . '</span> So it works, but i had to take the htmlspecialchars out of the echo and i THINK i should probably place it inside my truncate fucntion but I dont know how to do that.. any thoughts? A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
lindsayanng Posted August 10, 2010 Author Posted August 10, 2010 WOW I am seriously ON A ROLL!! I will definitely have to release this puppy as a contribution.. I have it so that name of the author now links to the reviews, the reviews are truncated and only will show a certain number.. WOO HOO Wanna see? My link No i think what I might do is wrap the whole thing in an if/else statement.. So if there are 0 reviews display a large "be the first to write a review" button.. A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
npn2531 Posted August 10, 2010 Posted August 10, 2010 You are really good at design,btw. That site looks really fresh and clean, just pretty. Completely appropriate for the items being sold. Oscommerce site: OSC to CSS, http://addons.oscommerce.com/info/7263 -Mail Manager, http://addons.oscommerce.com/info/8120
lindsayanng Posted August 10, 2010 Author Posted August 10, 2010 Thanks George, that is my my focus in my career.. the development side is a little more difficult but I still think i am better than most designers... The site isn't done yet, but it definitely has a nice look and feel.. I think this one might be my best one yet.. still a lot to do though/ A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.