Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

  • Index
  •  » ClickCartPro 6
  •  » Will Trade Product Comment Script for Help With Styling It Better

#1 01-07-2009 16:45:53

phattburban
Member
Registered: 12-10-2008
Posts: 4

Will Trade Product Comment Script for Help With Styling It Better

I found a good simple product review(comment) script on phptutorials.com that I modified for use with CCP6.  It will allow registered users to post comments about a particular product and inserts the comments and user info into another table in the db.  I was also able to create a new admin area in the manage users section of the core.  I played with the styling and have it looking 'ok' but it still doesn't fully look like the site product detail page.  Here is what I did.

1.  Use phpMyAdmin, Heidisql or something similar to create a new table in the db with this code...

Code:

-- 
-- Table structure for table `cmt_post`
-- 

CREATE TABLE `cmt_post` (
  `post_id` int(5) NOT NULL auto_increment,
  `p_name` varchar(40) NOT NULL,
  `dt` date NOT NULL,
  `name` varchar(25) NOT NULL,
  `email` varchar(50) NOT NULL,
  `dtl` text NOT NULL,
  `status` varchar(4) NOT NULL default 'ns',
  UNIQUE KEY `post_id` (`post_id`,`p_name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

2.  You'll have to create 3 files...cmt-display.php...cmt-form.php...cmt-formck.php

3.  cmt-display.php has this code...

Code:

<? 
$proddisp = $this->globals('ecom.prod_proddetail');
$xid      = $proddisp['id'];
$p_name   = $this->xhtml_encode($xid);
$query="select name, dtl, dt from cmt_post where p_name='$p_name' and status='apv' order by dt LIMIT 10";
$result=mysql_query($query);
$num_results = mysql_num_rows($result); 
if ($num_results > 0){ 
echo "<table width='400' border='0' cellspacing='0' cellpadding='1'>";
echo "__________________________________________________________________________";
while($row=mysql_fetch_array($result)){ $dtl=nl2br($row['dtl']);
echo "<tr bgcolor='#f1f1f1'><td>$row[name]</td><td align=right>".date("m-d-Y",strtotime($row['dt']))."</td></tr>";
echo "<tr><td  colspan=2>$dtl<hr /></td></tr>";
}
echo "</table>";
}
else
{ 
echo "There are no comments about this product yet.\r\n\r\n";
} 

?>

4.  cmt-form.php has this code...

Code:

<? 
$proddisp = $this->globals('ecom.prod_proddetail');
$xid      = $proddisp['id'];
$p_name   = $this->xhtml_encode($xid);
$app       = $this->globals('khxc_display.app');

echo "\n\n";
echo "__________________________________________________________________________\n\n";

echo "<table width='400' border='0' cellspacing='0' cellpadding='1'>
<form method=post action=''><input type=hidden name=todo value=post_comment><input type=hidden name=p_name value=$p_name><tr bgcolor='#f1f1f1'><td>Name</td><td><input type=text name=name></td></tr><tr ><td>Email</td><td><input type=text name=email>(Please enter your user account email)</td></tr><tr bgcolor='#f1f1f1'><td colspan=2><textarea name=dtl rows=3 cols=50></textarea></td></tr>
<tr ><td colspan=2 align=left><input class='khxc_formbutton' input type=submit value='Post Comment'></td></tr>
</table></form>
Only registered users may post a comment about a product.
";

?>

5.  cmt-formck.php has this code...

Code:

<? 
@$todo=$_POST['todo'];
if(isset($todo) and $todo=="post_comment"){

$p_name=$_POST['p_name'];
$p_name=mysql_real_escape_string($p_name);
$name=$_POST['name'];
$name=mysql_real_escape_string($name);
$email=$_POST['email'];
$email=mysql_real_escape_string($email);
$dtl=$_POST['dtl'];
$dtl=mysql_real_escape_string($dtl);

$query="select id FROM khxc_users where id='$email'";
$result=mysql_query($query);
$row = mysql_fetch_array($result);


$status = "OK";
$msg="";

// if userid is less than 3 char then status is not ok
if( strlen($name) <3 or strlen($name) > 25){
$msg=$msg."Your Name should be more than 2 and less than 25 char length<BR>";
$status= "NOTOK";}                         

if( strlen($dtl) <3 ){
$msg=$msg."Your comment should be more than 3 char length<BR>";
$status= "NOTOK";}                         

if ($row<1) {
$msg=$msg."Sorry you don't seem to be a registered user.  Please create an account and try again.";
$status= "NOTOK";}

if($status<>"OK"){ 
echo "<font face='Verdana' size='2' color=red>$msg</font>";
}else{ // if all validations are passed.
$dt=date("Y-m-d"); 
$status='apv'; // Change this to apv if you want all messages to be automatically approved once posted.
$query=mysql_query("insert into cmt_post(p_name,dt,name,email,dtl,status) values('$p_name','$dt','$name','$email','$dtl','$status')");
echo mysql_error();
echo "<font face='Verdana' size='2' color=green>Thank you for posting your comment<br></font>";
}
}

?>

6.  Next goto ClickCartPro > Displays: Skins, Menus, XHTML Includes and Messages > Manage XHTML Includes  page 2 and update Form: Footer with this code at the very end of the existing code...

Code:

<p class="khxc_storehead">User Comments About This Product</p>
<?php

$ns  = $this->globals('khxc.namespace');


if ($ns == 'prodshow') 
{ 
$this->include_file($app,'cmt-display.php'); // To display the comments
$this->include_file($app,'cmt-formck.php'); // Processing the form data
$this->include_file($app,'cmt-form.php'); // To display the form.
}

?>

7.  Ftp to your site and goto the your-private-directory/apps/ccp0/CCP/includes and upload cmt-display.php, cmt-form.php, and cmt-formck.php.

At this point the comments are ready to go and positioned on the product detail pages under the add to cart button.  The next thing to do is create the admin area in ccp6.

8.  Goto Hybrid X Core > Database: Connections, Backups and Raw Admin > Raw Database Admin area and browse the khxc_namespaces table.  On page 5 clone khxc.manageusers.  When it comes up to enter the info enter...

id                             khxc.manageuserscomments
namespace               manageuserscomments
name                       Manage User Comments
funcparams              cmt_post

Leave everything else the same and save it.  Now when you go in the User Accounts flyout menu you should have another choice to Manage User Comments.  Click on it and you'll see all comments that are made.

That's it your done.  You should have a working comment/review area on all product detail pages and an area in the admin panel to delete or change comments if needed. 

Since I'm still learning ccp6 and CSS I just need someone's help to make it look a little better.  You can see it in action on my site. wwwinstallerresource.com.  I haven't had a lot of people add comments yet, but if you click on the top left featured item (the bracket) there are a couple of comments there.

Thanks in advance.

Donny

Offline

 

#2 01-09-2009 04:28:56

sleeper
Member
Registered: 10-29-2004
Posts: 332

Re: Will Trade Product Comment Script for Help With Styling It Better

Hi Donny,

Well i would love to help, i'll definately use this mod so would love to give something back, send me a PM and we can discuss in more detail.


- Steve


Specialists in ClickCartPro Design

Offline

 

#3 01-09-2009 08:43:43

fullstock
Member
Registered: 12-05-2007
Posts: 85
Website

Re: Will Trade Product Comment Script for Help With Styling It Better

Installed this yesterday so I thought I would critique it.  The only thing I found so far is that customers can post more than one comment when the page is refreshed and post data is sent again.  Other than that the CSS I changed the background for name and email address fields to match my cart skin and everything looks integrated fine.

Offline

 

#4 01-09-2009 23:02:11

wyattea
Member
Registered: 01-07-2006
Posts: 1650

Re: Will Trade Product Comment Script for Help With Styling It Better

fullstock.net is forbidden 403.

Offline

 

#5 06-30-2009 10:00:07

sleeper
Member
Registered: 10-29-2004
Posts: 332

Re: Will Trade Product Comment Script for Help With Styling It Better

Bringing up another old post...

How can we add a selection list to the review form with prefilled data (i.e. could be a how did you hear about us, out of 10 rating list etc.)?


- Steve


Specialists in ClickCartPro Design

Offline

 

#6 07-02-2009 02:33:32

sleeper
Member
Registered: 10-29-2004
Posts: 332

Re: Will Trade Product Comment Script for Help With Styling It Better

Still trying to figure this out.

What i want to do is add a selection list (the variables of which do not change) for a star rating

selection 1
selection 2
selection 3
selection 4
selection 5

I can create another text column in the database to store the data from the selection, but my question is if i create another text column can i pass the data from a hard coded selection list to that field or do selection lists data not work like that.

By this i mean if the dislay/data value for selection 3 is '3 stars' will it post the value as text data to the database field?

Could do with a little help on this one...


- Steve


Specialists in ClickCartPro Design

Offline

 
  • Index
  •  » ClickCartPro 6
  •  » Will Trade Product Comment Script for Help With Styling It Better

Board footer