magento 评论回复功能

本文详细介绍了在数据库中新增字段、修改表单及输出回复功能的过程,并提供了关键代码片段。通过修改Form.php和Review.php文件,实现回复文本框的添加及获取,同时在list.phtml文件中增加回复输出,确保后台功能的完善。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.      数据库中review_detail表新增字段 reply


2.      修改Form.php文件,添加回复文本框,  app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php  96行

$fieldset->addField('created_at', 'text', array(
            'label'     => Mage::helper('review')->__('Posted On'),
            'required'  => true,
            'name'      => 'created_at'
        ));

135行

$fieldset->addField('reply', 'textarea', array(
            'label'     => Mage::helper('review')->__('Reply'),
            'required'  => false,
            'name'      => 'reply',
            'style'     => 'height:24em;',
        ));

3.      修改Review.php文件,添加表单获取字段,  app/code/core/Mage/Review/Model/Mysql4/ Review.php 95行

/**
         * save detale
         */
		if(!is_null($object->getReply())){
			$reply=$object->getReply();
		}else{
			$reply='';
		}
        $detail = array(
            'title'     => $object->getTitle(),
            'detail'    => $object->getDetail(),
            'nickname'  => $object->getNickname(),
            'reply'     => $object->getReply(),
        );

4.修改list.phtml文件,增加回复输出,app/design/frontend/default/eshopstandard/template/review/product/view/list.phtml   56行

<?php echo nl2br($this->htmlEscape($_review->getDetail())) ?>
                <small class="date"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></small>
		<p style="color: rgb(204, 0, 51);"><?php echo $this->__('Reply:') ?><?php echo nl2br($this->htmlEscape($_review->getReply())) ?></p>

1.5和1.6的问题:需要添加这个:
还得修改你的app\design\frontend\base\default\template\reviewform.phtml 为其添加一个书写回复的文本  可以隐藏 因为你是后台给添加的…. (不然你的产品评论会报错的…..)
<input type=”text” name=”reply” id=”summary_field” value=”<?php echo $this->htmlEscape($data->getTitle()) ?>” />

1.6需要改:

的是:/app/code/core/Mage/Review/Model/Resource/Review.php这个文件,,,文件路径不一样,。改法都一样,,稍微有了些变化

/app/code/core/Mage/Review/Model/Resource/Review/Collection.php



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值