关于YiiRewriteMap重写block的问题

bug问题 · Zeroer · 于 5年前 发布 · 1726 次阅读

product/Index可以实现重写:

'\fecshop\app\appfront\modules\Catalog\block\product\Index' => '\appfront\local\local_modules\Catalog\block\product\Index',

但是重写product\CustomOption类就重写不了:

'\fecshop\app\appfront\modules\Catalog\block\product\CustomOption' => '\appfront\local\local_modules\Catalog\block\product\CustomOption',
共收到 9 条回复
Fecmall#15年前 1 个赞

姿势不对,估计是大小写,或者哪里存在空格等,不易发现的小问题导致的。

仔细找找

Zeroer#25年前 0 个赞

@Fecshop #1楼 感谢解答... 不过检查了几次,用其它类也做了测试,是同样的结果,没有报错,但是$blockName打印输出的是index

Zeroer#35年前 0 个赞

@Fecshop #1楼 后台部分可以重写

Zeroer#45年前 0 个赞

YiiRewriteMap.php代码:

return [
    '\fecshop\app\appfront\modules\Catalog\block\product\CustomOption'  => '\appfront\local\local_modules\Catalog\block\product\CustomOption',
];

@appfront\local\local_modules\Catalog\block\product\CustomOption.php代码:

<?php
namespace appfront\local\local_modules\Catalog\block\product;

use Yii;

class CustomOption extends \fecshop\app\appfront\modules\Catalog\block\product\CustomOption
{
    public function getLastData()
    {
        ...
    }
}
Fecmall#55年前 0 个赞

把文件路径(文件结构树)抓图贴一下。(你先贴一下截图,晚上我测试看看)

Fecmall#75年前 0 个赞

这个一个bug

对于controller中直接调用的block,是可以重写的

而对于view中的index.php文件中使用下面的方式:

<div class="product_custom_options">
    <?php # custom options部分
        $optionsView = [
            'class' =>  'fecshop\app\appfront\modules\Catalog\block\product\CustomOption',
            'view'	=> 'catalog/product/index/custom_option.php',
            'custom_option' 	=> $custom_option,
            'attr_group'		=> $attr_group,
            'product_id'		=> $_id ,
            'middle_img_width' 	=> $media_size['middle_img_width'],
        ];
        $optionsParam = [
            
        ];
        
        
    ?>
    <?= Yii::$service->page->widget->render($optionsView,$optionsParam); ?>

</div>

则不会重写,这是一个bug,已经修复:https://github.com/fecshop/yii2_fecshop/commit/73ed48597de7af2c27b09b7d3a2120b9e51cc717

Fecmall#85年前 1 个赞

周末会发一个子版本。

Zeroer#95年前 0 个赞

@Fecshop #8楼 嗯嗯 好的

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics