Yii

Yii 2.0 hiding /basic/web from the URL along with the index.php

怎甘沉沦 提交于 2019-12-19 04:05:13
问题 Plenty of information around the net on how to hide the index.php from your Yii 2.0 application URL, however, what I'm trying to do here is to also remove the '/basic/web/' from the URL. /basic/web is the directory from which the application is running and the configuration that I have so far is the following. That goes into the config file: 'urlManager' =>[ 'enablePrettyUrl' => true, 'showScriptName' => false, ], And this is my htaccess file that I have within the /web folder: RewriteEngine

How to extend CListView in order to remove extra yii added markup?

霸气de小男生 提交于 2019-12-19 03:57:00
问题 The point is to remove from CListView render, those two divs: <div id="yw0" class="list-view"> <div class="items"> I've been looking here: https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php#L123 But I found nothing related with those two divs there. Can anyone please share, what should we extend in order for make this a reality ? Here's an update of the desired output: <div> <article class="itemthing"> list data </article> <article class="itemthing"> list data

gii not working in yii

南楼画角 提交于 2019-12-18 21:21:14
问题 I am new in yii framework. In my site gii shows the error Error 403 You are not allowed to access this page. I set the gii in the config file like this 'gii'=>array( 'class'=>'system.gii.GiiModule', 'password'=>'test123', 'ipFilters'=>array('192.168.0.101','127.0.0.1','::1'), ), still it show the error 回答1: This is the only line that worked for me: 'ipFilters'=>array($_SERVER['REMOTE_ADDR']), 回答2: You may set... 'ipFilters' => false From the docs http://www.yiiframework.com/doc/api/1.1

[Yii Framework] Add a link in CGridView

别等时光非礼了梦想. 提交于 2019-12-18 18:56:30
When we using CGridView in Yii, we may want to a link as a column. So in common sense, we will use CLinkColumn to do that, as these code: <? php $this -> widget( ' zii.widgets.grid.CGridView ' , array ( ' dataProvider ' => $dataProvider , ' columns ' => array ( array ( ' name ' => ' username ' , ' class ' => ' CLinkColumn ' , ' labelExpression ' => ' $data->username ' , ' urlExpression ' => ' Yii::app()->createUrl("admin/user", array("id"=>$data->id)) ' , ) , ) , )); ?> But we can not sort the username with this way. Thanks for Yii, we can use another way to do it. Here are the code: <? php

Why use CJSON encode when we have json_encode

不羁的心 提交于 2019-12-18 18:51:19
问题 I am building an API for a website using Yii. I know that there is a utility class called CJson and has a function called encode. As far as I know there are additional parameters that can be customized in the native json_encode function like the JSON_NUMERIC_CHECK which is really useful. It creates { "id": 17 } instead of Yii's CJSON encode which makes the '17' a string. { "id": "17" } So my question is whether there is any reason I should use CJSON encode instead of the built in PHP function

Why use CJSON encode when we have json_encode

偶尔善良 提交于 2019-12-18 18:49:59
问题 I am building an API for a website using Yii. I know that there is a utility class called CJson and has a function called encode. As far as I know there are additional parameters that can be customized in the native json_encode function like the JSON_NUMERIC_CHECK which is really useful. It creates { "id": 17 } instead of Yii's CJSON encode which makes the '17' a string. { "id": "17" } So my question is whether there is any reason I should use CJSON encode instead of the built in PHP function

Importing and saving data from csv file in yii

半世苍凉 提交于 2019-12-18 18:38:11
问题 This is what my csv file looks like: I have three fields ( import site , import goods , import status ) to import respective data. So if a user clicks on import site only sites name will get saved and the rest won't, similarly for import goods and import status . The site's data and status's data are saved in a single table but the goods data is being saved in other table with respect to it's site. How do i save them into multiple tables? 回答1: I will share simple snippet to parse csv files,

yii: how to make a unique rule for two attributes

你说的曾经没有我的故事 提交于 2019-12-18 11:40:54
问题 I have a table like this: (id, name, version, text). (name, version) is unique key, how can i make a rule to validate this. 回答1: This can be done by Yii itself, you do not need an extension for it. However an extension can help cleaning up the rules() method as described here: http://www.yiiframework.com/extension/unique-attributes-validator/ This is the code (copied from that site) which will work without using the extension: public function rules() { return array( array('firstKey', 'unique'

Dynamic creation of subdomains

假如想象 提交于 2019-12-18 11:17:50
问题 I'm creating a website using MVC framework (Yii) and I need to dynamically create subdomains, i.e. http://company.website.com So, in order to achieve this I've added a DNS wildcard (*.website.com). Now the problem is that my application controllers are all the same for www.website.com and for company.website.com. For example, I have a User controller with Register action ( user/register ). Now if I go to www.website.com/user/register I can register, but I can do exactly the same if I go to

Correct password is not accepted in Yii login

五迷三道 提交于 2019-12-18 09:43:25
问题 Hi i'm quite new to yii framework, currently trying to establish a login through database authentication. but while im trying to log in i get this error saying Please fix the following input errors: Password is incorrect. but when i check the database table im typing the correct password. can anybody help me out if this Heres the Controller <?php class SiteController extends Controller { public function actions() { return array( 'captcha'=>array( 'class'=>'CCaptchaAction', 'backColor'=