Jump to content
Larry Ullman's Book Forums

Yii Booster Not Working In Module


melaniecarr23
 Share

Recommended Posts

I was able to follow everything you wrote in the book on yii booster and modules and tested everything locally on my mac using MAMP.  It worked great.  Dropdown menus, tables with dropdown related filtering, editable fields, toggle fields.  Beautiful amazing module!  I uploaded it to the server and can't get booster to work at all.  I changed my yii booster menu to a CMenu version and it works, so I know it's got something to do with how I'm initializing or configuring yii booster.

 

main.php (I can't change the way URLs are done or preload booster for the whole site)

'modules'=>array(
		// uncomment the following to enable the Gii tool
 		'gii'=>array(
 			'class'=>'system.gii.GiiModule',
 			'password'=>'bypass',
 			// If removed, Gii defaults to localhost only. Edit carefully to taste.
 			'ipFilters'=>array('68.84.73.165','75.146.203.154','::1','2601:46:4200:3214:fc19:fc58:7775:6454','*'),
 			//enable extension giix
 			'generatorPaths' => array(
 				'ext.giix-core'),
 		),
 		'admin' => array( // admin module by Melanie
 			'class' => 'application.modules.admin.AdminModule',
 			'components' => array(
 				'booster' => array(
 					'class' => 'admin.extensions.booster.components.Booster'),
 				),
 			'preload' => array('booster'),
 			),
 		'pay', // sample stripe payment module
	),

// application components
	'components'=>array(

		'booster' => array(
			'class' => 'application.modules.admin.extensions.booster.components.Booster',
			'responsiveCss'=>true,
			),

		'user'=>array(
			// enable cookie-based authentication
			'allowAutoLogin'=>false,
		),
		// prevent CSRF attacks when using cookies set to true
		// must use CHtml or CActiveForm to create forms to work
		//'request'=>array(
		//	'enableCsrfValidation'=>true,
		//),
		'session' => array(
           'class' => 'CDbHttpSession',
           'autoCreateSessionTable' => true,
           'connectionID' => 'db',
           'timeout' => 2400,
           'autoStart' => true
        ),
		// uncomment the following to enable URLs in path-format
		
		'urlManager'=>array(
			//'urlFormat'=>'path',
			'rules'=>array(
				//'http://admin.pottstownrumble.net' => 'admin/default/index',
				//'http://admin.pottstownrumble.net/login' => 'admin/default/login',
				//'http://admin.pottstownrumble.com' => 'admin/default/index',
				//'http://admin.pottstownrumble.com/login' => 'admin/default/login',
				//'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				//'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				//'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),

AdminModule.php

<?php

class AdminModule extends CWebModule
{
	public function init()
	{
		
		Yii::app()->setComponents(array(
            'errorHandler' => array(
                'errorAction' => 'admin/default/error'),
            'user' => array(
                'class' => 'CWebUser',             
                'loginUrl' => Yii::app()->createUrl('admin/default/login'),
            )
        ));
 
		Yii::app()->user->setStateKeyPrefix('admin');
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		// import the module-level models and components
		$this->setImport(array(
			'admin.models.*',
			'admin.components.*',
			'admin.extensions.*',
		));
	}

	public function beforeControllerAction($controller, $action)
	{
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			$route = $controller->id . '/' . $action->id;
           // echo $route;
            $publicPages = array(
                'default/login',
                'default/error',
            );
            if (Yii::app()->user->isGuest && !in_array($route, $publicPages)){            
                Yii::app()->user->loginRequired();                
            }
            else


			return true;
		}
		else
			return false;
	}
}

DefaultController.php

<?php

class DefaultController extends Controller
{
	public $layout = 'xadmin';
	/*public function filters() {
	return array(
			array('booster.filters.BoosterFilter - delete')
			);
	}*/
	public function actionIndex()
	{
		$this->render('index');
	}
	/**
	 * Displays the login page
	 */
	public function actionLogin()
	{
		$model=new LoginForm;

		// if it is ajax validation request
		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}

		// collect user input data
		if(isset($_POST['LoginForm']))
		{
			$model->attributes=$_POST['LoginForm'];
			// validate user input and redirect to the previous page if valid
			if($model->validate() && $model->login())
				$this->redirect(Yii::app()->user->returnUrl);
		}
		// display the login form
		$this->render('login',array('model'=>$model));
	}

	/**
	 * Logs out the current user and redirect to homepage.
	 */
	public function actionLogout() {
        Yii::app()->user->logout(false);
        $this->redirect(Yii::app()->getModule('admin')->user->loginUrl);
    }
    public function actionError()
	{
		if($error=Yii::app()->errorHandler->error)
		{
			if(Yii::app()->request->isAjaxRequest)
				echo $error['message'];
			else
				$this->render('error', $error);
		}
	}
}

Directory Structure:

Protected->Modules->admin->extensions is where I put the booster folder I downloaded from the clever tech site.

 

Originally I had it in the Protected->extensions folder, and it worked fine that way until I uploaded it.  Then it didn't work.  All I got was a blue line across the top of the screen.

 

Can someone help me figure out how to run yii booster on all pages of the admin module?

 

Thanks,

Melanie

Link to comment
Share on other sites

admin/views/registrations/admin.php 

<?php

$this->breadcrumbs = array(
	$model->label(2) => array('index'),
	Yii::t('app', 'Manage'),
);

$this->menu = array(
		array('label'=>Yii::t('app', 'List') . ' ' . $model->label(2), 'url'=>array('index')),
		array('label'=>Yii::t('app', 'Create') . ' ' . $model->label(), 'url'=>array('create')),
	);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('registrations-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?></h1>

<p>
You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); ?>
<div class="search-form collapse">
<?php $this->renderPartial('_search', array(
	'model' => $model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('application.modules.admin.extensions.booster.widgets.TbExtendedGridView', array(
	'id' => 'registrations-grid',
	'dataProvider' => $model->search(),
	'filter' => $model,
	'type' => 'striped bordered condensed',
	'columns' => array(
            array(
                'name' => 'ID',
                'type'=>'raw',
                'value'=>'CHtml::link($data->ID,Yii::app()->createUrl("admin/players/registrationlinked/",array("id"=>$data->ID)))',
        	),
		array(
				'name'=>'transactionID',
				'value'=>'GxHtml::valueEx($data->transaction)', // change to text search
				),
		array(
				'name'=>'divisionLevelID',
				'header'=>'Division',
				'value'=>'GxHtml::valueEx($data->divisionLevel->division)',
				),
		array(
				'name'=>'divisionLevelID',
				'header'=>'Level',
				'value'=>'GxHtml::valueEx($data->divisionLevel->level)',
				),
		array(
				'name'=>'field',
				'value'=>'GxHtml::valueEx($data->field0)',
				'filter'=>GxHtml::listDataEx(Fields::model()->findAllAttributes(null, true)),
				), // filters appropriately
        array(
                'name' => 'net',
                'header' => 'Net',
                'class' => 'application.modules.admin.extensions.booster.widgets.TbEditableColumn',
                'headerHtmlOptions' => array('style' => 'width:30px'),
                'editable' => array(
                    'type' => 'text',
                    'url' => $this->createUrl('registrations/editable')
                )
            	),	
        array(
                'name' => 'team',
                'header' => 'Team #',
                'class' => 'application.modules.admin.extensions.booster.widgets.TbEditableColumn',
                'headerHtmlOptions' => array('style' => 'width:30px'),
                'editable' => array(
                    'type' => 'text',
                    'url' => $this->createUrl('registrations/editable')
                )
            	),	
        array(
                'name' => 'notes',
                'header' => 'Notes',
                'class' => 'application.modules.admin.extensions.booster.widgets.TbEditableColumn',
                'headerHtmlOptions' => array('style' => 'width:30px'),
                'editable' => array(
                    'type' => 'text',
                    'url' => $this->createUrl('registrations/editable')
                )
            	),	
		/*
		*/
		array(
			'class' => 'CButtonColumn',
		),
	),
)); ?>

Thought maybe some of my code with the widgets in it might help.  I've tried referencing the booster widgets various ways:

booster.widgets.TbExtendedGridView

ext.booster.widgets.TbExtendedGridView (when I had booster in the protected/extensions folder)

admin.extensions.booster.widgets.TbExtendedGridView (after I moved it to the protected/modules/admin/extensions folder

and finally

application.admin.extensions.bosoter.widgets.TbExtendedGridView

 

This is a big huge bummer.  I'm ready to pay someone for a few minutes to fix things for me, or even just to take a look at my site and guide me through what I'm missing to make things work.

Link to comment
Share on other sites

Yii1

 

I actually am working on two sites (my own and one I volunteer to help a nonprofit with).  The original guy did the site using Yii, but from what I'm able to see, he didn't do a lot of it the Yii way and it's making my life hell).

 

This is the nonprofit site and is using yii1 locally running mamp pro on my macbook, and remotely hosted at digital ocean using Ubuntu.  mysql is the db for both.

 

I wish I could just drive out to State College one day and soak up everything from you like a sponge!  :rolleyes:  

Link to comment
Share on other sites

 Share

×
×
  • Create New...