Search Results

Search found 119 results on 5 pages for 'yii'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • Yii urlManager language in URL

    - by TaMeR
    I am trying to add a language to the url with following syntax: http://www.example.com/en/site/page/view/about What I have so far works with short urls like: http://www.example.com/en/site/contact but not with long once as in my first example Here is what I have so far: /config/main.php 'urlManager'=>array( 'class'=>'application.components.MyCUrlManager', 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( '<language:\w+>/<controller:\w+>/<id:\d+>'=>'<controller>/view', '<language:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<language:\w+>/<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ), <?php // components/MyCUrlManager.php class MyCUrlManager extends CUrlManager { public function createUrl($route,$params=array(),$ampersand='&') { if(isset($_POST['_lang'])){ Yii::app()->language = $_POST['_lang']; }elseif (!isset($route['language']) && $controller != 'srbac'){ $route['language']=Yii::app()->language; }else{ Yii::app()->language = $route['language']; } return parent::createUrl($route, $params, $ampersand); } } ?> class Controller extends CController: { /// ..... function init() { parent::init(); if (isset($_POST['_lang'])) { Yii::app()->setLanguage($_POST['_lang']); Yii::app()->session['_lang'] = Yii::app()->language; }elseif (isset(Yii::app()->session['_lang'])) { Yii::app()->setLanguage(Yii::app()->session['_lang']); } } } class LangBox extends CWidget { public function run() { $currentLang = Yii::app()->language; require_once 'Zend/Locale.php'; $locale = new Zend_Locale(); //$siteLanguages = $this->getLang(); $siteLanguages = array('en','de','tr'); foreach($siteLanguages as $value){ $list[$value] = $locale->getTranslation($value, 'Language', $value); } asort($list); $this->render('langBox', array('currentLang' => $currentLang, 'list'=>$list)); } }

    Read the article

  • How does one track down an error using the YII Framework?

    - by ian
    I am learning the Yii Framework and I got this error wich does not really point to the specific pages I am working on or as far as i can tell show me where I should start looking for my problem. How do I make sense of this? As far as I can see all my 'type_id' references are typed in correctly. CException Description Property "Project.type_id" is not defined. Source File /Users/user/Dropbox/localhost/yii/framework/db/ar/CActiveRecord.php(107) 00095: */ 00096: public function __get($name) 00097: { 00098: if(isset($this->_attributes[$name])) 00099: return $this->_attributes[$name]; 00100: else if(isset($this->getMetaData()->columns[$name])) 00101: return null; 00102: else if(isset($this->_related[$name])) 00103: return $this->_related[$name]; 00104: else if(isset($this->getMetaData()->relations[$name])) 00105: return $this->getRelated($name); 00106: else 00107: return parent::__get($name); 00108: } 00109: 00110: /** 00111: * PHP setter magic method. 00112: * This method is overridden so that AR attributes can be accessed like properties. 00113: * @param string property name 00114: * @param mixed property value 00115: */ 00116: public function __set($name,$value) 00117: { 00118: if($this->setAttribute($name,$value)===false) 00119: { Stack Trace #0 /Users/user/Dropbox/localhost/yii/framework/db/ar/CActiveRecord.php(107): CComponent->__get('type_id') #1 /Users/user/Dropbox/localhost/trackstar/protected/views/project/_view.php(15): CActiveRecord->__get('type_id') #2 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(119): require('/Users/user/Dro...') #3 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88): CBaseController->renderInternal('/Users/user/Dro...', Array, true) #4 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(748): CBaseController->renderFile('/Users/user/Dro...', Array, true) #5 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CListView.php(215): CController->renderPartial('_view', Array) #6 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CBaseListView.php(152): CListView->renderItems() #7 [internal function]: CBaseListView->renderSection(Array) #8 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CBaseListView.php(135): preg_replace_callback('/{(\w+)}/', Array, '{summary}?{sort...') #9 /Users/user/Dropbox/localhost/yii/framework/zii/widgets/CBaseListView.php(121): CBaseListView->renderContent() #10 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(174): CBaseListView->run() #11 /Users/user/Dropbox/localhost/trackstar/protected/views/project/index.php(17): CBaseController->widget('zii.widgets.CLi...', Array) #12 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(119): require('/Users/user/Dro...') #13 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88): CBaseController->renderInternal('/Users/user/Dro...', Array, true) #14 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(748): CBaseController->renderFile('/Users/user/Dro...', Array, true) #15 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(687): CController->renderPartial('index', Array, true) #16 /Users/user/Dropbox/localhost/trackstar/protected/controllers/ProjectController.php(148): CController->render('index', Array) #17 /Users/user/Dropbox/localhost/yii/framework/web/actions/CInlineAction.php(32): ProjectController->actionIndex() #18 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(300): CInlineAction->run() #19 /Users/user/Dropbox/localhost/yii/framework/web/filters/CFilterChain.php(129): CController->runAction(Object(CInlineAction)) #20 /Users/user/Dropbox/localhost/yii/framework/web/filters/CFilter.php(41): CFilterChain->run() #21 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(999): CFilter->filter(Object(CFilterChain)) #22 /Users/user/Dropbox/localhost/yii/framework/web/filters/CInlineFilter.php(59): CController->filterAccessControl(Object(CFilterChain)) #23 /Users/user/Dropbox/localhost/yii/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain)) #24 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(283): CFilterChain->run() #25 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array) #26 /Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(320): CController->run('') #27 /Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(120): CWebApplication->runController('project') #28 /Users/user/Dropbox/localhost/yii/framework/base/CApplication.php(135): CWebApplication->processRequest() #29 /Users/user/Dropbox/localhost/trackstar/index.php(12): CApplication->run() #30 {main} 2011-10-17 18:17:18 Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 Yii Framework/1.1.2

    Read the article

  • Yii PHP Framework- Implementation

    - by Josh
    I was just curious if Yii is supposed to be compiled into PHP or not. Is it possible to use Yii just by copying the Framework to a folder on the server and then including something (something as in one of the yii files- I am not sure how it works) in the scripts I wish to use the framework for? (Noob when it comes to frameworks and usage) Thanks, Josh

    Read the article

  • Yii: Multi-language website - best practices.

    - by michal
    Hi, I find Yii great framework, and the example website created with yiic shell is a good point to start... however it doesn't cover the topic of multi-language websites, unfortunately. The docs covers the topic of translating short messages, but not keeping the multi-lingual content ... I'm about to start working on a website which needs to be in at least two languages, and I'm wondering what is the best way to keep content for that ... The problem is that the content is mixed extensively with common elements (like embedded video files). I need to avoid duplicating those commons ... so far I used to have an array of arrays containing texts (usually no more than 1-2 short paragraphs), then the view file was just rendering the text from an array. Now I'd like to avoid keeping it in arrays (which requires some attention when putting double quotations " " and is inconvenient in general...). So, what is the best way to keep those short paragraphs? Should I keep them in DB like (id | msg_id | language | content ) and then select them by msg_id & language? That still requires me to create some msg_id's and embed them into view file ... Is there any recommended paradigm for which Yii has some solutions? Thanks, m.

    Read the article

  • Yii Framework Tutorial - file not found

    - by Heshan Perera
    I am in the process of learning the Yii Framework. I have been following this Tutorial. I have followed all the steps and have by index page loading. In my index.php page I point to two other pages located in protected/views/message The following is the code in my index.php located in the message folder mentioned above. <html> <body> <h1>Welcome</h1> <p> To view our message go to... <?php echo CHtml::link('Here', '/message/show')?> </p> <p> To edit our message go to... <?php echo CHtml::link('Here', '/message/edit')?> </p> </body> </html> "message" is the ID I gave when generating the model and controller through the yii shell application. The problem is, after the above page loads, and I click on any one of the above URLs, it points to "localhost:8080/message/show" and "localhost:8080/message/edit" , whereas the real location of these files is "localhost:8080/test/protected/views/message/..." What could I be doing wrong ?

    Read the article

  • Problem with a test method in Yii web services

    - by Conrad
    Hi There, Is there anyone here who might be familiar with web services in the yii framework? I declared the following test method: /** * Send a single SMS message * * @param string $username Username * @param string $password Password * @param string $identifier Valid Identifier to use * @param string $mobileNumber Mobile Number to send message to * @param string $message Message to send * @return string 'OK' on success, error message on failure * @soap */ public function singleSms($username, $password, $identifier,$mobileNumber, $message){ return "username=$username, pwd=$password, source=$identifier, mobno=$mobileNumber, msg=$message"; } But when I try to call this method I get the following response: - - WSDL - SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://sms.chillnethosting.co.za/index.php?r=sms/webservice' : Start tag expected, '<' not found The WSDL generates when I call my URL: Web Service URL Any Ideas?

    Read the article

  • Insert coding query in yii

    - by nerd
    I need to auto insert the next orders_id into an Orders table in a database. orders_id is not the primary Key, and it does not auto-increment I need to query the database, find the last (highest) id value, increment 1, and insert it in Orders table in database. Actually, I have a shipping action which will provide address of shipping of orders. So as soon as the user fills address form and move to payments page, I want to simultaneously fill my Orders table by max(orders_id)+1. I have built relations between Address table and Orders table but my orders Table is not getting populated. Please detail me correct codes to implement it in my controller in Yii

    Read the article

  • Dropdown dependent values to be fetch from multiple models using ajax in Yii

    - by newuser
    I searched all the documentation over Yii but not got the answer of it.So I came here finally. I have the following schema Table Schools +------------------+--------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------+------+-----+---------------------+----------------+ | id | int(10) | NO | PRI | NULL | auto_increment | | school_name | varchar(100) | NO | | | | +------------------+--------------+------+-----+---------------------+----------------+ Table Students +------------------+--------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------+------+-----+---------------------+----------------+ | id | int(10) | NO | PRI | NULL | auto_increment | | school_id | int(10) | NO | FK | | | | student_name | varchar(100) | NO | | | | | roll_no | varchar(80) | NO | | | | | class | varchar(20) | NO | | | | | | subjects | varchar(100) | NO | | | | +------------------+--------------+------+-----+---------------------+----------------+ I have made models and CRUD for the both models.In models my relation is like this In Students.php the relation is like 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( 'School' => array(self::BELONGS_TO,'Schools','school_id'), ); } In Schools.php the relation is like 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( 'student' => array(self::HAS_MANY, 'Students', 'school_id'), ); } Now I made the two models rendered in a single page so that I can enter all the respective fields in a single form. In the _form.php file of Students I have made some change in student_name like this <div class="row"> <?php echo $form->labelEx($model,'student_name'); ?> <?php echo $form->dropdownList($model,'student_name', CHtml::listData(Students::model()->findAll(), 'id', 'student_name'), array('empty'=>array('Select'=>'--Select One---'))); ?> <?php echo $form->error($model,'student_name'); ?> Now for this piece of code I got all the student name from the Student model. So my problem is when I am getting the student name from the dropdown list and going to select a student it will also fetch all the respective values of the student to be rendered in the _form.php without click on save button.So that user don't have to put it again manually. I think ajax and json encode will work here but don't know how to make them work here. [Update] Here is StudentsController code public function actionDisCoor() { $model = School::model()->findByPk($_POST['Students']['student_id']); $data=CHtml::listData($data,'id','name'); foreach($data as $value=>$name) { echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true); } } Here is _form.php code for Students <div class="row"> <?php echo $form->labelEx($model,'student_name'); ?> <?php $List = CHtml::listData(Students::model()->findAll(), 'id', 'student_name'); ?> <?php echo $form->dropdownList($model,'student_name',$List, array('onChange'=>CHtml::ajax(array( 'url' => CController::createUrl('DisCoor'), 'type' => 'POST', 'update'=>'#school_id', )),'style'=>'width:180px;' ) )?> <?php echo $form->error($model,'student_name'); ?> </div> After all that when I saw in firebug I got the error.Here is the screen shot

    Read the article

  • Yii, Generate unquie ids one each tr element of CGridView

    - by Snow_Mac
    I have a CDbActiveRecord setup and I have a instance of the CGridView class setup as a widget. Basically my end game is I need a table, but each row to contain the primary key of the row associated with the Active Record. Such as: <tr id="123"> <td> Column value 1 </td> <td> Col 2 </td> <td> Col 3 </td> </tr> That's the specific of the row that I'm looking for. Here's the code I've got so far to produce a table. (The json variable is set because this is inside a controller and the widget is returned as json.) // get the content id for the version list $contentID_v = Yii::app()->request->getParam("id"); // setup the criteria to fetch related items $versionCdbCriteria = new CDbCriteria; $versionCdbCriteria->compare("contentID",$contentID_v); // setting up the active data provider for the version $vActiveDP = new CActiveDataProvider("FactsheetcontentVersion", array( "criteria" => $versionCdbCriteria, 'pagination' => array('PageSize' => $this->paginationSize), 'keyAttribute'=>'vID', )); $json_data .= $this->widget('zii.widgets.grid.CGridView', array( 'dataProvider' => $vActiveDP, 'columns' => array( 'title', 'created', 'createdBy' ), 'showTableOnEmpty' => 'false', ),true); This is what it produces for my active record. <div class="grid-view" id="yw0"> <div class="summary">Displaying 1-1 of 1 result(s).</div> <table class="items"><thead> <tr><th id="yw0_c0">Factsheettitle</th> <th id="yw0_c1"><a href="jq/work/admin/index.php?r=factsheetManager/Editor &amp;id=25601&amp;getV=true&amp;_=1341694154760&amp;FactsheetcontentVersion_sort=created">Created</a> </th> <th id="yw0_c2"><a href="jq/work/admin/index.php?r=factsheetManager/ Editor&amp;id=25601&amp;getV=true&amp;_=1341694154760&amp;FactsheetcontentVersion_sort=createdBy">Created By</a> </th> </tr></thead> <tbody><tr class="odd"><td>Distribution</td><td>0000-00-00 00:00:00</td><td>NULL</td></tr></tbody> </table> <div title="jq/work/admin/index.php?r=factsheetManager/Editor&amp;id=12&amp;id=25601&amp;getV=true&amp;_=1341694154760" style="display:none" class="keys"><span>8</span></div> </div>

    Read the article

  • A CMS based on Yii ?

    - by santa_cametotown
    Hi - i've been with Yii for a few months and before I use main CodeIgniter, SilverStripe in my projects. Does anyone know a good Yii based CMS such as SilverStripe based on Sapphire or EE based on CodeIgniter ? My experience is working with Yii is much more easier and straightforward assuming you are good OOP coder but Yii is still young and there are not lot of samples that I can put together quickly for a real prodcution project. A couple of YII based CMS I spotted at do not look really promising or maybe at a very early stage such as dotPlant, Web3CMS.

    Read the article

  • Need help choosing between Grails and Yii Framework

    - by user530207
    I recently started on developing in PHP with the Yii Framework. I recently came across the Grails Framework and I'm pretty impressed by the sites they make, bigger companies seem to use Grails for their web development. When looking at yii, not many big companies are using it. I'm just starting out with the Yii framework and I don't want to turn back halfway when in the middle of learning Yii, so I hope someone can give me some comparison about the 2 in terms of power. Does Grails make things much easier and benefit me in the long run? I only have C++ background for now. It boils down to this. I want a powerful framework which will serve me for a very long time and by looking at the number of big companies using Grails, I feel discouraged to take the Yii path. Thank you! Some sites by Grails: http://video.sky.com/ http://espn.go.com/ http://www.atlassian.com/ http://www.linkedin.com/

    Read the article

  • YII Mail Generate unwanted ascii character in HTML mail

    - by CedSha
    I use YII-Mail just by copying the sample but I always get some ascii charcters in my generated links Where they come from and how to avoid them ? $message = new YiiMailMessage; $message->view = 'mail'; $message->setBody(array('model'=>$model), 'text/html'); $message->subject = Yii::t('tr','my subject'); $message->addTo('[email protected]'); $message->from = '[email protected]'; Yii::app()->mail->send($message); and in view file 'mail' <h1><?php echo(Yii::t('tr','This is HTML mail')); ?></h1> <?php echo CHtml::link('Mylink', array('controller/view', 'id'=>$model->id)); ?> The resulted email source looks like this <h1>This is HTML mail</h1> <a href=3D"/testdrive/index.php?r=3D ....

    Read the article

  • How to specify a SEO friendly url like twitter www.twitter.com/<name> using YII framework

    - by hip10
    Hi, I am currently using the Yii framework, and I would like to know if anyone has any clue on how to setup a SEO friendly url like www.twitter.com/ automatically in Yii? I know how to do so this manually in the config/main.php but I would like to be able to dynamically generate it. I have been able to do it in Grails as well. In Yii, what I know of is that you need to have another parameter like www.twitter.com/l/, but I do not want that parameter, anyone can share? Thanks.

    Read the article

  • Avoid htaccess redirecting to one folder Yii

    - by JG Estevez
    I have a website running over Yii Framework, I created a folder in the root path named blog, I installed a wordpress blog under this folder, but the files .htaccess that comes with yii is trying to redirect my request to www.domain.com/blog to the controller/action type which I don't want, I want to treat the blog folder as a completely app with no relation to yii. here is what I've done so far Options +FollowSymLinks IndexIgnore */* RewriteEngine on RewriteCond %{REQUEST_URI} "/blog/" RewriteRule (.*) $1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php as you can see I added the conditions to avoid redirecting for the blog folder but when I try to access the the url is telling me The page isn't redirecting properly. How can I solve this?? thanks

    Read the article

  • Failed opening 'SiteTest: Firefox.php' when running Yii Functional Test

    - by Phelios
    Warning: include(): Failed opening 'SiteTest: Firefox.php' for inclusion ... \yii\framework\YiiBase.php on line 418 Yii v1.1.10 PHPUnit v3.6.10 PHPUnit_Selenium v 1.2.6 I get this error when trying to run the example on the book "Agile Web Development with Yii 1.1 and PHP5" I kind of feel that there is a problem with the phrase SiteTest:, it shouldn't be there. But, how do I fix this? UPDATE (SOLVED): Apparently, the problem is not the warning shown above, but there is another error down the road. It says that "curl_init()" is undefined. I already enabled the php_curl extension, but the PHP from CLI is not using the same .ini file as the apache one. So, after I enabled the php_curl in the CLI version of the ini, it works fine now (still giving the warning, but the test is running).

    Read the article

  • How to create multiple inputs in yii + Q&A admin page

    - by user1764357
    In yii, i am developing page for Creating Question with multiple options using forms. So i have two tables Question QuestionId Question optionId Option OptionId Option To create multiple options, option field should be provided with add button so that after clicking add button, it should display new textbox control to get the new option. All these options displayed in a gridview. So can you please help me. I am very new to yii.

    Read the article

  • Using Yii framework, what would be a right way to process an attribute before displaying it using CH

    - by Karolis
    Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?> start_time is a UNIX timestamp. When just displaying it in a view I can apply functions like date() on it. Where should I apply the formatting when I'm displaying it in a form, by using the above line of code? (This case of timestamps/dates might be special, but I'm also interested in how would one go about if it wasn't a date and I just want to work with "value in database" < "different representations of the value in different views. Thanks =)

    Read the article

  • Yii include PHP Excel

    - by Anton Sementsov
    Im trying include PHPExcel lib to Yii, put PHPExcel.php in root of extensions, near PHPExcel folder and added that code into config/main.php // application components 'components'=>array( 'excel'=>array( 'class'=>'application.extensions.PHPExcel', ), modify /protected/extensions/PHPExcel/Autoloader.php public static function Register() { $functions = spl_autoload_functions(); foreach($functions as $function) spl_autoload_unregister($function); $functions=array_merge(array(array('PHPExcel_Autoloader', 'Load')), $functions); foreach($functions as $function) $x = spl_autoload_register($function); return $x; }// function Register() Then, trying create PHPExcel object $objPHPExcel = new PHPExcel(); but have an error: include(PHPExcel.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in Z:\home\yii.local\www\framework\YiiBase.php(418)

    Read the article

  • Yii: Saving date and time in DB

    - by FaisalKhan
    I am having trouble saving the date in DB through Model. In my controller, if I dump the date in log that I receive from $_POST , I get the date in this format "10/Nov/2012 07:30". If I use: $AccountAppointment->start_date=Yii::app()->dateFormatter->format($_POST['AccountAppointment']['start_date'], 'dd/M/yyyy HH:mm'); I get the error: Invalid datetime format: 1292 Incorrect datetime value: '10/NoGMT+5/2012 07:30' for column 'start_date' Changing the format in dateFormatter to 'dd/M/yyyy HH:mm' or 'dd/MM/yyyy HH:mm' or 'dd/MMM/yyyy HH:mm' throws the same error. Db is MySQL 5.0, Yii version 1.1.12. Any help would be greatly appreciated, I am almost stuck....thanks....

    Read the article

1 2 3 4 5  | Next Page >