想在产品页面添加自定义内容,请问是哪几个文件控制的?
看不懂,什么是自定义内容
在产品里添加了一个属性“referee”,想让referee的值出现在产品页面。
http://www.fecshop.com/doc/fecshop-guide/instructions/cn-1.0/guide-fecshop_product.html
@KaiJuan [[#3楼](#comment3)](#comment3) 谢谢!我是想修改这上面的内容:产品页面
没弄懂怎么去调用数据库
@Aswe [#4楼](#comment4)
http://www.fecshop.com/topic/624
先去学习下如何发帖描述清楚问题吧,看不懂
想在产品页下的"add to cart"下方增加个按钮"url of referee",点击按钮转向推荐人的微博。
这个按钮需要检测是否已登录。
”url of referee“的值已事先保存在产品信息里。
数据层:https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/modules/Catalog/block/product/Index.php
theme层:https://github.com/fecshop/yii2_fecshop/blob/master/app/appfront/theme/base/front/catalog/product/index.php
判断用户是否登录,Yii2知识,自行查阅
@Fecshop [#7楼](#comment7) 对fecshop还不熟,请多指教:
mongodb和theme部分已重写,检查没问题。直接在@fecshop下的fecshop\app\appfront\modules\Catalog\block\product\Index.php增加
'url_referee' => $this->_product['url_referee'],
没有问题,能取到数据并正常显示到页面。
现在把Index.php文件复制到appfront\local\local_modules\Catalog\block\product下编辑:
namespace appfront\local\local_modules\Catalog\block\product; ... ... 'url_referee' => $this->_product['url_referee'],
,url_referee没有返回值,也没报错。
YiiRewriteMap:
return [ /** * \fecshop\models\mongodb\Category 为原来的类 * \appfront\local\local_models\mongodb\Category 为重写后的类 * 重写后的类可以集成原来的类。 */ '\fecshop\models\mongodb\Category' => '\appfront\local\local_models\mongodb\Category', '\fecshop\models\mongodb\Product' => '\appfront\local\local_models\mongodb\Product', '\fecshop\app\appfront\modules\Catalog\block\product' => '\appfront\local\local_modules\Catalog\block\product', // '\fecshop\app\appfront\modules\Cms\block\home\Index' => '\appfront\local\local_modules\Cms\block\home\Index', // '\fecshop\app\appfront\modules\Catalog\block\product\CustomOption' => '\appfront\local\local_modules\Catalog\block\product\CustomOption', ];
我是不是漏步骤了?
@Fecshop #9楼 这个字段要用产品属性组的方法?没明白
解决了,YiiRewriteMap写错。改正后正常:
'\fecshop\app\appfront\modules\Catalog\block\product\Index' => '\appfront\local\local_modules\Catalog\block\product\Index',
重写功能很方便