Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'yii'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



  1. Hello guys I was confused to what Yii::app()->name meant. I know that Yii::app() is calling the static function app() in the YiiBase class, but there is no property name in that same class, can someone explain?
  2. I have been using the Yii Book to create an admin module for a site I didn't create that uses the yii framework. I was able to successfully create the module, apply login functionality to it, and implement Yii booster for extendedgrid functionality with inline editing. I can link the text from a column using the foreign key relation to a different model's view (primary key) and display those results using the TbExtendedGridView. What doesn't seem to work for me is displaying the results according to a different attribute other than the primary key. Link: http://mysites.com/index.php?r=admin/registrations/adminlinked&id=29 http://mysites.com/index.php?r=admin/registrations/divisionLevel&id=3 RegistrationController: public function actionAdminLinked($id) { $model = $this->loadModel($id, 'Registrations'); $this->performAjaxValidation($model, 'registrations-form'); if (isset($_POST['Registrations'])) { $model->setAttributes($_POST['Registrations']); if ($model->save()) { $this->redirect(array('view', 'id' => $model->ID)); } } $this->render('adminlinked', array( 'model' => $model, )); } public function actionDivisionlevel($id) { $model=Registrations::model()->with('divisionLevel','division','level','players')->findAllByAttributes(array( 'divisionLevelID'=>$id, )); $this->performAjaxValidation($model, 'registrations-form'); $this->render('adminlinked', array( 'model' => $model, )); } Note: I'd like to add the ability to display player names (2 to 4 depending on the registration), division and level names (through divisionLevel relations). actionAdminLinked displays results correctly. actiondivisionLevel displays a blank screen. What on earth am I doing wrong that I can't seem to get this to work? I've tried for hours.
  3. Hi, Is there a way to change the default db connection for a particular controllers actions. I want to switch between two database connection in my action, how do I do it ? I have configured both the database in my main.php file, like: 'db'=>array( 'connectionString' => 'mysql:host=;dbname=mydb', 'emulatePrepare' => true, 'username' => 'root', 'password' => '1111', 'charset' => 'utf8', ), 'db2'=>array( 'class'=>'CDbConnection', 'connectionString' => 'mysql:host=;dbname=mydb', 'emulatePrepare' => true, 'username' => 'root', 'password' => '2222', 'charset' => 'utf8', ), How do I switch between these two database connection in my controller's action ?
  4. My url is : http://localhost/Pramod/Revite-1/event/view1?var1=a&var2=b and i wanted it to display as: http://localhost/Pramod/Revite-1/event/view1/a/b How can i achieve this using .htaccess file. Plz help.
  5. Hello Everyone, I have implemented the chapter 22 "CREATING A CMS" as exactly as explained in the book. I have done all the setup for elastic search that is: - downloaded elasticsearch and run from terminal - install from composer - take the search controller from github source - added the view files - changed the code of index.php file as instruction I can see the search box in the URL http://localhost/%5BPROJECT_NAME%5D/index.php/search.The probelm is when I search any word i.e. "alice", I am getting error like: {"error":"IndexMissingException[[pages] missing]","status":404} Can someone tell me why I am getting this error? Thanks
  6. Larry, Do you have any more chapters of the Yii Book? I mean the second edition, revised for Yii 2. I've read -- and mostly understood -- up to page 190, which is the last revised page. If you have more revised chapters, I'd be interested in reading them. No doubt, other readers would too. Can you post any additional chapters on your website and let everyone know? Thanks.
  7. Hello Larry, I read your book twice. Honestly I do not understand very well. I have already learned from your books, specially the e-commerce. I like the principle of explanation by example. In Yii, you go well in the way of doing your best and understand the subtle mechanisms of this framework. So, I yii installs and works correctly. I followed your chapters and wanted to better understand your example. Now i would like test your example CMS. I am unable to launch the application of Cms version of Chapter 22 of your book. The window is hopelessly empty. I notice in the index.php : $compose = dirname (__ FILE __) '/ protected / vendor / autoload.php.'; I do not see a vendor folder in protected'folder and evidently no autoload.php I have my composer.phar in protected folder. Is the problem here? Thanks for advice cordialy
  8. Hi can you give me some reasons to use YII framework?
  9. Hi Larry, Im a very big fan of yours Larry, and I really love your books. I've learned PHP from you than my prof in school when i was still studying. I just want to know larry if you have plans in writing a book in zend? Coz im trying to learn another framework since you have mentioned that it's best to learn atleast 2 frameworks. But unfortunately other books are really hard to understand. Or do you think it's best for me to just focus in Yii alone. Thanks Larry! Jan
  10. I want to render a Model view completely in the CJuiDialog box. in actionIndex() i have pagination only for three records on the page public function actionIndex() { $dataProvider=new CActiveDataProvider('Jobs',array( 'pagination'=>array( 'pageSize'=>3, ),)); $this->render('index',array( 'dataProvider'=>$dataProvider, )); } the view of first three records display on the CJuiDialog as apopup. up to this working fine. the problem is when i click on next page of pagination then it renders all view of the next records on the index page with the list view. code is- actionView() public function actionView($id) {if (Yii::app()->request->isAjaxRequest) { //outputProcessing = true because including css-files ... $this->renderPartial('view', array( 'model'=>$this->loadModel($id), ),false,true); //js-code to open the dialog if (!empty($_GET['asDialog'])) echo CHtml::script('$("#dlg-address-view").dialog("open")'); Yii::app()->end(); } else $this->render('view',array( 'model'=>$this->loadModel($id), )); } index.php <?php $this->breadcrumbs=array( 'Jobs', ); $this->menu=array( array('label'=>'Create Jobs','url'=>array('create')), array('label'=>'Manage Jobs','url'=>array('admin')), ); ?> <h1>Jobs</h1> <?php $this->widget('bootstrap.widgets.TbListView',array( 'dataProvider'=>$dataProvider, 'itemView'=>'_view', )); ?> _view.php <?php $target = 'window.location='."'".$this->createUrl('jobs/index')."'"; $dialogId = "dialog_{$data->job_id}"; $this->beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=>$dialogId, // additional javascript options for the dialog plugin 'options'=>array( 'title'=>$data->job_title, 'autoOpen'=>false, 'show'=>array( 'effect'=>'blind', 'duration'=>1000, ), 'hide'=>array( 'effect'=>'explode', 'duration'=>500, ), 'buttons' => array( array('text'=>'Route','click'=> 'js:function(){'.$target.'}'), array('text'=>'Cancel','click'=> 'js:function(){$(this).dialog("close");}'), ), 'height'=>500, 'width'=>450, 'show'=>'fade', 'hide'=>'fade', ), )); $this->renderPartial('/jobs/view',array('model'=>$data)); $this->endWidget('zii.widgets.jui.CJuiDialog'); // the link that may open the dialog echo CHtml::link(CHtml::encode($data->job_id), '#', array( 'onclick'=>'$("#'. $dialogId .'").dialog("open"); return false;', )); ?> view.php <?php $this->widget('bootstrap.widgets.TbDetailView',array( 'data'=>$model, 'attributes'=>array( array( 'name'=>'job_id', // only admin user can see person id 'visible'=>Yii::app()->user->name=='admin'? true : false, ), array('name'=>'job_code','label'=>'Job Code'), array('name'=>'job_title','label'=>'Title'), array('name'=>'job_desc','label'=>'Description'), array('name'=>'job_lastdate','label'=>'Last Date'), 'job_photo', 'job_file', array( //'label'=>'Ad Photo', 'type'=>'raw', 'value'=>CHtml::tag('img', array("title"=>$model->job_photo, "src"=>Yii::app()->baseUrl."/images/".$model->job_photo, "style"=>"width:400px") ) ), //'job_createtime', ), )); ?> what is wrong in my code? i am not getting anything. i just think the problem is that of ajax request. because going to next page in the pagination is ajax request and because of this pagination the view of record (view.php) is partially rendered on the listview of index.php but what will be the solution to avoid this?? help me please Thank you.
  11. hello everyone.. i have a form to store values for a model add having rows id name description and one is email to store email for particular entry. Now i want a contact form to send mail for that particular model values... that is to send mail to the owner of particular add.. I able to reuse contact form for that purpose but i fail to fetch saved email id for each add so that any viewer can mail for adds.. How to achive this task?? please help me someone.. let me know the how can i do this?? if any example code will be very useful to me.. Thank you.....
  12. I want to render comment form in the view.php of add controller task is submitting comment for the particular add of things... i created comment model controller and required view files sql schema for comment table is-- CREATE TABLE IF NOT EXISTS `tbl_comment` ( `cid` INTEGER NOT NULL AUTO_INCREMENT, `add_id` INTEGER, `user_id` INTEGER, `user_name` varchar(1000), `description` varchar(2000), `create_time` DATETIME, PRIMARY KEY(`cid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; ALTER TABLE `tbl_comment` ADD CONSTRAINT `FK_comment_add` FOREIGN KEY (`add_id`) REFERENCES `tbl_add` (`addid`) ON DELETE CASCADE ON UPDATE RESTRICT; ALTER TABLE `tbl_comment` ADD CONSTRAINT `FK_comment_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT; sql schema for add is-- CREATE TABLE `tbl_add` ( `username` varchar(50) NOT NULL, `addid` int(11) NOT NULL, `addname` varchar(100) NOT NULL, `category` varchar(100) NOT NULL, `description` varchar(1000) NOT NULL, `city` varchar(50) NOT NULL, `address` varchar(500) NOT NULL, `mobile` varchar(100) NOT NULL, `email` varchar(100) NOT NULL, `image` varchar(100) NOT NULL, `price` varchar(100) NOT NULL, `createtime` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY(`addid`) UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CommentController.php <?php class CommentController extends Controller { //I Faisal Added this code. /** * @var private property containing the associated Project model instance. */ private $_add = null; /** * @var string the default layout for the views. Defaults to '//layouts/column2', meaning * using two-column layout. See 'protected/views/layouts/column2.php'. */ public $layout='//layouts/column2'; /** * Protected method to load the associated add model class * @add_id the primary identifier of the associated add * @return object the Add data model based on the primary key */ protected function loadAdd($add_id) { //if the add property is null, create it based on input id if($this->_add===null) { $this->_add=Add::model()->findbyPk($add_id); if($this->_add===null) { throw new CHttpException(404,'The requested ADD does not exist.'); } } return $this->_add; } /** * In-class defined filter method, configured for use in the above filters() method * It is called before the actionCreate() action method is run in order to ensure a proper project context */ /** * added Filter class to project to filter the add so user can select * valid projects and process its issues */ public function filteraddContext($filterChain) { //set the project identifier based on either the GET or POST input //request variables, since we allow both types for our actions $addId = null; if(isset($_GET['pid'])) $addId = $_GET['pid']; else if(isset($_POST['pid'])) $addId = $_POST['pid']; $this->loadAdd($addId); //complete the running of other filters and execute the requested action $filterChain->run(); } //////////////////END OF MY CODE/////////// /** * @return array action filters */ public function filters() { return array( 'accessControl', // perform access control for CRUD operations 'postOnly + delete', // we only allow deletion via POST request //I Faisal Added following filter 'addContext + create index admin', //check to ensure valid project context ); } /** * Specifies the access control rules. * This method is used by the 'accessControl' filter. * @return array access control rules */ public function accessRules() { return array( array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=>array('index','view'), 'users'=>array('*'), ), array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions'=>array('create','update'), 'users'=>array('@'), ), array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions'=>array('admin','delete'), 'users'=>array('admin'), ), array('deny', // deny all users 'users'=>array('*'), ), ); } /** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $this->render('view',array( 'model'=>$this->loadModel($id), )); } /** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model=new Comment; //I Faisal Added the project model property for the above instance of issue to assign for the perticular project $model->add_id = $this->_add->addid; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Comment'])) { $model->attributes=$_POST['Comment']; $model->user_name=Yii::app()->user->name; $model->create_time=date("d m y G:i:s "); if($model->save()) $this->redirect(array('view','id'=>$model->cid)); } $this->render('create',array( 'model'=>$model, )); } /** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Comment'])) { $model->attributes=$_POST['Comment']; if($model->save()) $this->redirect(array('view','id'=>$model->cid)); } $this->render('update',array( 'model'=>$model, )); } /** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } /** * Lists all models. */ public function actionIndex() { /* added to only get comment for a particular add only*/ $dataProvider=new CActiveDataProvider('Comment', array( 'criteria'=>array( 'condition'=>'add_id=:addId', 'params'=>array(':addId'=>$this->_add->addid), ), )); $this->render('index',array( 'dataProvider'=>$dataProvider, )); } /** * Manages all models. */ public function actionAdmin() { $model=new Comment('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['Comment'])) $model->attributes=$_GET['Comment']; $this->render('admin',array( 'model'=>$model, )); } /** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model=Comment::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; } /** * Performs the AJAX validation. * @param CModel the model to be validated */ protected function performAjaxValidation($model) { if(isset($_POST['ajax']) && $_POST['ajax']==='comment-form') { echo CActiveForm::validate($model); Yii::app()->end(); } } } comment/_form.php <?php /* @var $this CommentController */ /* @var $model Comment */ /* @var $form CActiveForm */ ?> <div class="form"> <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'comment-form', 'enableAjaxValidation'=>false, )); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php //echo $form->labelEx($model,'add_id'); ?> <?php //echo $form->textField($model,'add_id'); ?> <?php //echo $form->error($model,'add_id'); ?> <?php echo $form->hiddenField($model,'add_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'user_id'); ?> <?php echo $form->textField($model,'user_id'); ?> <?php echo $form->error($model,'user_id'); ?> </div> <div class="row"> <?php //echo $form->labelEx($model,'user_name'); ?> <?php //echo $form->textField($model,'user_name',array('size'=>60,'maxlength'=>1000)); ?> <?php //echo $form->error($model,'user_name'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'description'); ?> <?php echo $form->textArea($model,'description',array('size'=>60,'maxlength'=>2000)); ?> <?php echo $form->error($model,'description'); ?> </div> <div class="row"> <?php //echo $form->labelEx($model,'create_time'); ?> <?php //echo $form->textField($model,'create_time'); ?> <?php echo $form->hiddenField($model,'create_time',array('value'=>date("d m y G:i:s "))); ?> <?php //echo $form->error($model,'create_time'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?> </div><!-- form --> add/view.php <?php /* @var $this AddController */ /* @var $model Add */ $Comment = new Comment("create"); $this->breadcrumbs=array( 'Adds'=>array('index'), $model->addname, ); $this->menu=array( array('label'=>'List Add', 'url'=>array('index')), array('label'=>'Create Add', 'url'=>array('create')), array('label'=>'Update Add', 'url'=>array('update', 'id'=>$model->addid)), array('label'=>'Delete Add', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->addid),'confirm'=>'Are you sure you want to delete this item?')), array('label'=>'Manage Add', 'url'=>array('admin')), array('label'=>'Create Comment', 'url'=>array('comment/create', 'pid'=>$model->addid)), ); ?> <?php $this->widget('bootstrap.widgets.TbDetailView', array( 'data'=>$model, 'type'=>'condensed', 'attributes'=>array( 'username', 'addname', 'category', 'description', 'city', 'address', 'mobile', 'email', 'image', 'price', array( 'label'=>'imzzzage', 'type'=>'raw', 'value'=>CHtml::tag('img', array("title"=>"CollegeLogo", "src"=>Yii::app()->baseUrl."/images/".$model->image, "style"=>"height:200px") ) ), ), )); echo CHtml::link("contact this add publisher ",array('add/contactpublisher','id'=> $model->addname)); //$this->renderPartial('/comment/create', array('model'=>$Comment)); ?> <br /> <h2>Comments</h2> <?php $this->widget('zii.widgets.CListView', array( 'dataProvider'=>$commentDataProvider, 'itemView'=>'/comment/_view', )); ?> <?php $this->renderPartial('/comment/create',array('model'=>$Comment,)); ?> Comment.php model code is <?php /** * This is the model class for table "tbl_comment". * * The followings are the available columns in table 'tbl_comment': * @property integer $cid * @property integer $add_id * @property integer $user_id * @property string $user_name * @property string $description * @property string $create_time * * The followings are the available model relations: * @property Users $user * @property Add $add */ class Comment extends CActiveRecord { /** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return Comment the static model class */ public static function model($className=__CLASS__) { return parent::model($className); } /** * @return string the associated database table name */ public function tableName() { return 'tbl_comment'; } /** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('description', 'required'), array('add_id, user_id', 'numerical', 'integerOnly'=>true), array('user_name', 'length', 'max'=>1000), array('description', 'length', 'max'=>2000), array('create_time', 'safe'), // The following rule is used by search(). // Please remove those attributes that should not be searched. array('cid, add_id, user_id, user_name, description, create_time', 'safe', 'on'=>'search'), ); } /** * @return array relational rules. */ public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'user' => array(self::BELONGS_TO, 'Users', 'user_id'), 'add' => array(self::BELONGS_TO, 'Add', 'add_id'), ); } /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'cid' => 'Cid', 'add_id' => 'Add', 'user_id' => 'User', 'user_name' => 'User Name', 'description' => 'Description', 'create_time' => 'Create Time', ); } /** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search() { // Warning: Please modify the following code to remove attributes that // should not be searched. $criteria=new CDbCriteria; $criteria->compare('cid',$this->cid); $criteria->compare('add_id',$this->add_id); $criteria->compare('user_id',$this->user_id); $criteria->compare('user_name',$this->user_name,true); $criteria->compare('description',$this->description,true); $criteria->compare('create_time',$this->create_time,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); } } when accessing view for the add it display error Property "Comment.addname" is not defined. i tried my level best but i unable to solve this problem i want to display all comments for each add also at the end a comment form to submit new comments and refresh that page and display the comment.. i think something is going wrong in public function relations() {....} of comment model please help me to solve this... thanks....
  13. i have to tables that are link and i want to view contents of a single item when i select it, what is the correct syntax of using $post in yii ie SELECT tbl_emp.emp_id, tbl_emp.sname, tbl_fname, tbl_educ.empl_id FROM tbl_emp, tbl_edu WHERE tbl_emp.emp_id=$_POST['emp_id'] AND tbl_edc.emp_id=$_PSOT['emp_id'];
  14. Hi, I am using this extension to display the google map in my page. And i have a text field that have been adding dynamically. I want to display the text field values in the google map. How to pass the text field values into the google map functionality. view.php <div id="map_section"> <div class="country_travell" style="background-color: #F8F8F8"> <?php foreach($countriesTravelled as $i => $countryTravelled) { $isCloseRequired = ($i==0) ? false : true; $this->renderPartial('_country_travelled', array('countryTravelled'=> $countryTravelled, 'i' => $i, // Row or iterator 'form'=>$form, 'isCloseRequired'=>$isCloseRequired)); } ?> </div> </div> <div id="gmap"> <?php $this->renderPartial('gmap',array('flagMap1'=>$flagMap)); ?> </div> _country_travelled.php <div class="floatLeft txt-input" rel="col1" style="width:150px;"> <?php echo $form->textField($countryTravelled, "[$i]place", array('onchange'=>'getPlaceName(this.value);', 'style' => 'width: 150px;')); ?> </div> script.js function getPlaceName(vl) { alert(vl); $.ajax({ type: 'POST', url: '<?php echo Yii::app()->createUrl("site/showGmap"); ?>', data:'place='+vl, success:function(data) { // alert(data); // if success $("#gmap").append(data); jQuery("#gmap").load("<?php echo Yii::app()->createUrl('site/showGmap'); ?>"); }, error: function(data) { // if error occured alert("Error occured...! Please try again"); }, dataType:'html' }); // $("#gmap").load("gmap.php"); } Controller.php public function actionShowGmap() { $place=$_POST["place"]; // echo $place; exit; [b]$this->render('gmap', array('place'=>$place));[/b] } In the controller i'm getting the value of place. and i want to pass the same place value in to the gmap. Please anyone help me
  15. Hi, I got all the way through the tutorial with no problems until the very end. In “EmployeeController.php” I’m trying to get yii to display the relation for department rather than the ID number. I have tried this code in the loadModel method: $model=Employee::model()->with('department')->findByPk((int)$id); I have double checked all of my relations and they all seem to be in order. It’s still showing the ID number rather than the department name. Any ideas? Thanks
  16. Hello, I am working through the tutorial for Yii on the website, and I have setup the Employee and Department models. However, this only addresses if an Employee has 1 department. What would I need to do if I wanted to be able to list multiple departments under the column 'departmentId' separated by commas or pipes, etc?
  17. Hi Larry, I don't know if this is the best place to place such a question, but I'm little confused. There is a framewok out there called Laravel, they talking about it so much, some people even excited about it. Which one is the easiest one to start with ?
  18. Hey guys, I created a controller 'PageController.php' with a default action 'actionShow' like this: public function actionShow( $slug = '' ) { if ( empty( $slug ) ) { $model=Pages::model()->findByAttributes( array( 'slug' => 'accueil' ) ); } else { $model = Pages::model()->find('slug = :slug', array(':slug' => $slug)); if($model===null) { throw new CHttpException(404,'The requested page does not exist.'); } } $this->render('page', array( 'model' => $model, 'slug' => $slug, )); } Then I created a module (and this is where things got problems) called "admin", and declared it in config/main.php And I set up the urls in config/main.php like that: 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', '<module:\w+>/<controller:\w+>/<action:[0-9a-zA-Z_\-]+>/<id:\d+>' => '<module>/<controller>/<action>', '<module:\w+>/<controller:\w+>/<action:[0-9a-zA-Z_\-]+>' => '<module>/<controller>/<action>', '<module:\w+>/<controller:\w+>' => '<module>/<controller>/index', '<slug:\w+>'=> 'page/show', ), ), The problem is when I call the page : maydomain.com/admin, it been processed as a slug for the page and not as a module, I fixed in the actionShow by : Is there is a way more clean than this ?
  19. Hi Going through the Yii book, now on the section about 2Hiding the Index File" I aready had several projects in my web folder, so I put the code for the book in a folder called yiibook. So to get the index page, I navigate to http://localhost:90/yiibook/ I updated my htaccess file to RewriteRule ^(.*)$ yiibook/index.php/$1 Which I think is correct. Its not entirely clear to me what should happen. At the moment, if I type in http://localhost:90/yiibook/bob Then it looks like the index page is displayed, and I get a message stating: Error 404 Unable to resolve the request "bob". Now I'm getting to my actual question! There is only one htaccess file. If I enter an invalid address in one of my other projects, I will get redirected to the yiibook index file. For example, lets say I have a project called mytest. If I browse to http://localhost:90/mytest/bob I will end up at the yiibook index page. This would probably not matter in a production website, as there would only be one project. But what do you other developers do when testing on your own PCs? Thanks Diarmuid
  20. So I'm just starting out with Yii and I'm trying to figure out the best way to organize my project. It's largely focused on being local, so I want to have different sections of the site for different cities. I have a city table in my database and I want to organize my URL as such: www.example.com/city-name. For example, if I want to show Chicago, it would be www.example.com/chicago. Right now I have a City controller and my cities are all attached to numeric id's. So my Chicago city (id = 1) URL reads as www.example.com/city/1. I want to get rid of my city controller name in the URL and use the name of the city instead of the id of the city in the URL. I'm assuming the answer lies in this part of the documentation (yes I've tried looking at the documentation): http://www.yiiframework.com/doc/guide/1.1/en/topics.url#using-custom-url-rule-classes - but I'm too new at Yii to decipher that code. First of all, is this the best way to organize my site and secondly, how do I get my URLs to look the way I want? Thanks so much - I've been struggling with this for a couple weeks. Sorry I'm a noob.
  21. Hello Larry, I am absolutely enjoying your book so far. It has been very very helpful to my web development skills. I was wondering if you were going to do a topic on deployment. I didn't see it listed in the table of contents so I wasn't sure. Assuming that it is on the agenda, I also assume that it will be discussed later on towards the end of the book. In the meantime, is there another course of action to take if I have to deploy a Yii website now? Another book that you highly recommend or another website or a SME perhaps? Any information you can provide would be very much appreciated. Take care... Sam
  22. How can I work with a specific Time Zone inside my Application in Yii ?
  23. Barely installed Yii and already ran into trouble. I'm running Windows 7 and use Wamp and MySQL for my database. After installation, I went to the url http://localhost/myproject/index.php?r=gii and selected Model Generator. I've edited both main.php and console.php in C:\wamp\www\myproject\protected\config folder to include the following: 'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=myproject', 'emulatePrepare' => true, 'username' => 'myproject', 'password' => 'thepassword', 'charset' => 'utf8', ) However, when trying to preview the model, the first field "Database Connection" gives me the following error: "A valid database connection is required to run this generator." I had the previous line in comments, and now tried changing into: 'db'=>array( 'connectionString' => 'mysql', ), Although it did not help. I've tried googling around and people have had similar problems, but editing both of the files solved their problems. For some reason it won't work for me. Is 'localhost' all I need to point it to wamp and phpMyAdmin? Can you help?
  24. Hello, i'm a beginner at yii and i was hoping you could help me. i couldnt find a simmilair post so i sorry if i double post. i used : http://www.larryullman.com/2010/01/07/custom-authentication-using-the-yii-framework/ but i have a strange error. when i press the login button on my app. i get this error. include(leraarCode.php): failed to open stream: No such file or directory The strange thing is. the model is leraar. but i want leraarCode as username i followed every step. But somehow $model is appointed leraarCode instead of leraar :S And i cant find how it happend :/ http://pastebin.com/22pxH1TU (login.php) http://pastebin.com/vqf3Sxvq (useridentity.php) http://pastebin.com/TeqbUtyQ (loginform.php) http://pastebin.com/aPiLVh1p (sql for the model) Thanks for your time in advance. Greetings, Teutates
  25. Hi all! I've followed the authentication tutorials here, but i wonder if Yii has a workaround for using both cookies and sessions for authentication. I want to allow use of the "remember me" button, but still save the roles, emails and such in sessions for security. Acording to the yii-manual the CBaseUserIdentity::setState will use cookies if its enabled, and use sessions if its set to false. Im thinking about a solution where you save a sha1($username $password) in the cookie, and make a method that gathers the other information in a auto-load-if-logged-in sort of way, but im not sure how secure it is, and if it might put to much unnessesary stress on the DB-server. Anyone made anything like that work, or has any idea? Edit: tags turned out wrong, cant seem to edit them. authentication spelled wrong, and also stuck together with cookies tag.
  • Create New...