fecshop小部件

问题咨询 · dream · 于 5年前 发布 · 1830 次阅读
<?php
				$parentThis['products'] = $bestSellerProducts;
				$parentThis['name'] = 'best-seller';
				$config = [
					'view'  		=> 'cms/home/index/product.php',
				];
				echo Yii::$service->page->widget->renderContent('category_product_price',$config,$parentThis);
			?>

最后这一句的renderContent()第一个参数是小部件的名称吗,是可以随便起名的吗。 render('header',[])的第一个参数在小部件配置中是可以找到的,不过renderContent的category_product_price没找到。

共收到 4 条回复
Fecmall#15年前 0 个赞

写一下文件路径?

Fecmall#25年前 0 个赞

render() 和 函数 renderContent(), 是两个函数

render() 在这里有讲解:http://www.fecshop.com/doc/fecshop-guide/instructions/cn-1.0/guide-fecshop_widget.html

对于 renderContent() 函数, category_product_price,是可以随便写的,只是用于标记,和出问题的时候报错

protected function actionRenderContent($configKey, $config, $parentThis = '')
    {
        if (isset($config['cache']['enable']) && $config['cache']['enable']) {
            if (!isset($config['class']) || !$config['class']) {
                throw new InvalidConfigException('in widget ['.$configKey.'],you enable cache ,you must config widget class .');
            } elseif ($ob = new $config['class']()) {
                if ($ob instanceof BlockCache) {
                    $cacheKey = $ob->getCacheKey();
                    if (!($content = CCache::get($cacheKey))) {
                        $cache = $config['cache'];
                        $timeout = isset($cache['timeout']) ? $cache['timeout'] : 0;
                        unset($config['cache']);
                        $content = $this->renderContentHtml($configKey, $config, $parentThis);
                        CCache::set($cacheKey, $content, $timeout);
                    }

                    return $content;
                } else {
                    throw new InvalidConfigException($config['class'].' must implete fecshop\interfaces\block\BlockCache  when you use block cache .');
                }
            }
        }
        // 查看 $config['class'] 是否在YiiRewriteMap重写中存在配置,如果存在,则替换
        $config['class'] = Yii::mapGetClassName($config['class']);
        $content = $this->renderContentHtml($configKey, $config, $parentThis);

        return $content;
    }
dream#35年前 0 个赞

@fecshop\services\page\Widget.php 第109行,actionRenderContent的注释,我以为也是从小部件的配置去找呢,好滴,明白了,谢谢!

Fecmall#45年前 0 个赞

@dream #3楼 开发过程中的代码结构调整,有一些注释没有改过来,这个改一下注释

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