跪求关于Magento的学习文档!!!!
跪求关于Magento的学习文档!!!!
你跪错地方了. http://www.magentochina.org/
缘木求鱼
这是是YII学习的地方。
突然发现有2个ActiveForm 【yii\bootstrap\ActiveForm 和 yii\widgets\ActiveForm 】
想知道这2个Activeform 有啥区别呢?分别适合什么场景?
你可以看代码,yii\bootstrap\ActiveForm继承了yii\widgets\ActiveForm
问题1:
授权章节的RBAC中,首先提到:@yii/rbac/migrations,我通过搜索找到了这个目录的物理路径:Site\vendor\yiisoft\yii2\rbac。
在之后的“使用规则”小节里,举栗代码的命名空间为“app\rbac;”,这个时候的rbac位于何处?
如果要书面化这个命名空间,是否等同于:@app\rbac,那么@app的物理路径在哪?
如果等同于models、views文件夹,我学习的是基础模板,是否需要自己创建rbac文件夹。
问题2:
> ……在用 yii rbac/init 执行了这个命令后……
yii rbac/init是什么?怎么用?
以上,希望前辈们给予解答。
app\rbac
的位置:
你说的对。目录 rbac
默认不存在,需要自己添加。./yii rbac/init
是一个 console command.
把 Building Authorization Data 中提到的 RbacController.php
保存到如下位置:
之后在 Basic Template 根目录下执行
// 先执行sql: SELECT * FROM customer LIMIT 100;
// SELECT * FROM orders WHERE customer_id IN (1,2,...)
$customers = Customer::find()->limit(100)
->with('orders')->all();
foreach ($customers as $customer) {
// 在这个循环的时候就不会再执行sql了
$orders = $customer->orders;
// ...handle $orders...
}
照着文档里这么做,然后获取到的$orders是一个对象,如下:
yii\db\ActiveQuery Object
(
[sql] =>
[on] =>
[joinWith] =>
[select] =>
[selectOption] =>
[distinct] =>
[from] =>
[groupBy] =>
[join] =>
[having] =>
[union] =>
[params] => Array
(
)
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
[where] =>
[limit] =>
[offset] =>
[orderBy] =>
[indexBy] =>
[modelClass] => common\models\AuthAssignment
[with] =>
[asArray] =>
[multiple] =>
[primaryModel] => common\models\Admin Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[username] => admin
[password_hash] => $2y$13$oYZrIQgTsipWdcNMKWCf8uxOIS286hOif9VWxf7.xnQ31MBje5AtS
[auth_key] => GQF9VeroKHrdo_72dzEF6SheBBOG-cuR
[status] => 1
[created_at] => 0
[last_time] => 1452569448
[ip] => 127.0.0.1
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 6
[username] => admin
[password_hash] => $2y$13$oYZrIQgTsipWdcNMKWCf8uxOIS286hOif9VWxf7.xnQ31MBje5AtS
[auth_key] => GQF9VeroKHrdo_72dzEF6SheBBOG-cuR
[status] => 1
[created_at] => 0
[last_time] => 1452569448
[ip] => 127.0.0.1
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
[authitem] =>
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
[beforeInsert] => Array
(
[0] => Array
(
[0] => Array
(
[0] => yii\behaviors\TimestampBehavior Object
(
[createdAtAttribute] => created_at
[updatedAtAttribute] => updated_at
[value] =>
[attributes] => Array
(
[beforeInsert] => Array
(
[0] => created_at
[1] => updated_at
)
[beforeUpdate] => updated_at
)
[owner] => common\models\Admin Object
*RECURSION*
)
[1] => evaluateAttributes
)
[1] =>
)
)
[beforeUpdate] => Array
(
[0] => Array
(
[0] => Array
(
[0] => yii\behaviors\TimestampBehavior Object
(
[createdAtAttribute] => created_at
[updatedAtAttribute] => updated_at
[value] =>
[attributes] => Array
(
[beforeInsert] => Array
(
[0] => created_at
[1] => updated_at
)
[beforeUpdate] => updated_at
)
[owner] => common\models\Admin Object
*RECURSION*
)
[1] => evaluateAttributes
)
[1] =>
)
)
)
[_behaviors:yii\base\Component:private] => Array
(
[0] => yii\behaviors\TimestampBehavior Object
(
[createdAtAttribute] => created_at
[updatedAtAttribute] => updated_at
[value] =>
[attributes] => Array
(
[beforeInsert] => Array
(
[0] => created_at
[1] => updated_at
)
[beforeUpdate] => updated_at
)
[owner] => common\models\Admin Object
*RECURSION*
)
)
)
[link] => Array
(
[item_name] => id
)
[via] =>
[inverseOf] =>
)
我要怎么处理这个对象,以获取我两个数据表数据的集合,初学者求教
$customers = Customer::find()->limit(100)
->with('orders')->**asArray()**->all();
楼上正解,加上asArray()返回的就是正常的数组了
yii2和bootstrap怎么配合,比如我用了$form->field()会自动生成一些html,其中的css是明显和bootstrap有关系的,这个时候如果我想改一下css怎么办。
例如,默认生成的是这个样子的:
但是我嫌它太长了,用options加了class=col-lg-6,但是换行了
于是我用了template:
<?= $form->field($model, 'modules_name',['template'=>"<div class='col-lg-6'>{label}\n{input}\n{hint}\n{error}</div>"])->textInput() ?>
这样的话,显示正常了,但是不至于每个field都加一个template吧,有没有其他方案解决啊
或者是推荐个其他方案。
统一的样式可以在开头统一配置,个性化的设置只能每个filed单独配置。
在页面里加js代码块,直接用jquery加你想应用的样式
表示yii2的activeform非常不灵活
2.0 的默认主题是否可以彻底换掉.
关于 表单小部件 不兼容其他样式类么..
代码信息:
<?= $form->field($model, 'username',['class' => 'form-control input-lg' , 'placeholder' => '用户名 / 邮箱 / 手机']) ?>
错误信息:
ReflectionException
Class form-control input-lg does not exist
此问题毁在我手里面了..写完就找到答案了!..
正确的写法:
<?= $form->field($model, 'username')->textInput(['class' => 'form-control input-lg' , 'placeholder' => '用户名 / 邮箱 / 手机']) ?>
呵呵呵!.. 真天真..
下一个问题:按顺序加载的js 会受到组件加载的js 影响 js冲突 和 错误
按照图里信息还可以看到yii加载jquery 和一些其他的东西 ,因为我之前有加载过 jquery 所以一定会冲突!..
这里的class不是指css样式,是指php的类。
原来是这样。那后面的 placeholder 也是php类?
如上图,直接用composer下载下来的,部署后就报上面的问题,我观察了下,多了以下目录:
首先这个问题,不能这么解决。
你需要把Composer和fxp/composer-asset-plugin都更新到最新版本。
其次看fxp/composer-asset-plugin的文档来配置对应的路径。
切记不要修改框架源码,如果是框架的BUG你应该提供一个pull request或者issues,以供官方修复。
这个需要到www.yiiframework.com去看看了,这边的貌似没有跟进。你需要按着最新的方法来创建文件。
图看不见,楼主
看你错误路径和目录本来就不一样啊,
你把文件目录按照 错误提示 重新拷贝下试试
用composer好像又慢又容易出错,直接用下载归档文件多好
说说我的解决方法吧,我的开发和部署环境都是linux,所以我用了proxychain,这个可以让你在命令行下用代理的神器。当然,首先你得有一个国外的 代理,然后走着代理安装,速度就杠杠的了。
多说一句,yii2用composer安装,仅仅使用国内的composer源镜像速度也很慢的,原因在于fxp/composer-asset-plugin这个插件。
怎么去掉 验证码前面的字母?
$form->field($model, 'verifyCode', ['template' => "{input}\n{hint}\n{error}"])->widget(Captcha::className()..........
打开源码,删除verify code.
我只能说这么多了
设置’template’属性
这个URL http://admin.demo.com/articletype/index.html?page=2&per-page=1 怎么重写伪静态啊 怎么写他的规则啊 求个样式
articletype/index/2:1.html
articletype/index/page/2/per-page/1.html
http://www.yiichina.com/topic/4327
哎,有现成的,都不会找么…
如题,在yii2中怎么加载一个ico图标
和别的网站一样的处理方式,没啥不一样
ico没有专门的加载吧,就放在根目录就行了吧
利用调试工具看一下资源文件有没有正常加载