2

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....

the following thinks i have done.

Create a widget view in extensions/widget/login/views/hloginForm.php with this codes

<?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"> &nbsp; </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 :

<?php 
class Login extends CWidget
{
    public function run()
    {
            $this->render('hloginForm');
    }
}
?>

and made all extensions as autoload in config/main.php

as

    'import'=>array(
            ...
            'application.extensions.*',
    ),

then try to use it in my webpage view file as

widget('Login'); ?>

this throw me this error

Quote

include(Login.php) [function.include]: failed to open >stream: No such file or directory

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. Make sure it points to an >existing PHP file and the file is readable.

tereško
  • 58,060
  • 25
  • 98
  • 150
  • Actually the folder path should be [your app name]/protected/extensions/widget/login/Login.php. Don't forget set permission for your Login folder. – Telvin Nguyen Aug 23 '13 at 10:03
  • 1
    `'application.extensions.*',` is not sufficient. Yii paths are not recursive, wo your class will not be found. Try `application.extendions.widgets.login.*` instead. Also make sure, your file is called `Login.php` not `login.php`. – Michael Härtl Aug 23 '13 at 10:32
  • @MichaelHärtl 'application.extensions.*' is not recursive, it's true but we don't need this declaration on the config to make extension work, it was not the cause absolutely. – Telvin Nguyen Aug 23 '13 at 10:57
  • @all i have found the solution for the problem. Access permission is the main issue for the extension folder. after i changed the permission it works fine. Thanks one and all. – Jothi Sankar N Kanakavel Aug 27 '13 at 04:50

1 Answers1

0

Changing the Access permission for the extension folder fixes the problem. After that it works fine as expected.