[英]Creating widget as an extension in Yii
I am very new to YII and its extensions... i am trying to create the basic login widget as an extension so that i can reuse it.... 我对YII及其扩展名非常陌生...我正在尝试将基本登录小部件创建为扩展名,以便我可以重用它。...
the following thinks i have done. 以下认为我已经做到了。
Create a widget view in extensions/widget/login/views/hloginForm.php with this codes 使用以下代码在extensions / widget / login / views / hloginForm.php中创建窗口小部件视图
<?php echo CHtml::beginForm($this->url, 'post', $this->htmlOptions); ?>
<div class="form header">
<table>
<tr>
<td>
<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username',array('class'=>'txt')); ?>
<?php echo $form->error($model,'username'); ?>
</div>
<div class="row rememberMe">
<?php echo $form->checkBox($model,'rememberMe'); ?>
<?php echo $form->label($model,'rememberMe',array('class'=>'dull')); ?>
<?php echo $form->error($model,'rememberMe'); ?>
</div>
</td>
<td>
<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password',array('class'=>'txt')); ?>
<?php echo $form->error($model,'password'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'Forget Password?',array('class'=>'dull')); ?>
</div>
</td>
<td>
<div class="row"> </div>
<div class="row">
<?php echo CHtml::submitButton('Login',array('class'=>'logbtn')); ?>
</div>
</td>
</tr>
</table>
and created a Login.php in main widget folder (that is : application/extensions/widget/login/login.php) with the code like : 并在主窗口小部件文件夹(即:application / extensions / widget / login / login.php)中创建了Login.php,其代码如下:
<?php
class Login extends CWidget
{
public function run()
{
$this->render('hloginForm');
}
}
?>
and made all extensions as autoload in config/main.php 并在config / main.php中将所有扩展名设置为autoload
as 如
'import'=>array(
...
'application.extensions.*',
),
then try to use it in my webpage view file as 然后尝试在我的网页视图文件中将其用作
this throw me this error 这给我抛出这个错误
Quote 引用
include(Login.php) [function.include]: failed to open >stream: No such file or directory
include(Login.php)[function.include]:无法打开> stream:没有这样的文件或目录
Tell me whats Wrong??? 告诉我出了什么事??? What should i do to get my Widget in my page.
我应该怎么做才能在页面中获取我的小部件。
and once i tried this 一旦我尝试了
$this->widget('application.extensions.widget.login.Login', array());
i got this error 我得到这个错误
Quote 引用
Alias "application.extensions.widget.login.Login" is invalid.
别名“ application.extensions.widget.login.Login”无效。 Make sure it points to an >existing PHP file and the file is readable.
确保它指向现有的PHP文件,并且文件可读。
Changing the Access permission for the extension folder fixes the problem. 更改扩展文件夹的访问权限可以解决此问题。 After that it works fine as expected.
之后,它按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.