yii-url-manager

yii2:- how can i manage angularjs post request in yii2

江枫思渺然 提交于 2019-12-13 15:38:31
问题 I am trying to send post request from angular controller to yii front end controller. Here is my controller.js 'use strict'; define(['angular', 'd3', 'd3Cloud', 'services'], function (angular, d3) { /* Controllers */ return angular.module('oc.controllers', ['oc.services']) .controller('InitCtrl', ['$scope','$http', function ($scope,$http) { $scope.loginFun = function() { var formData = {username:$scope.txtUserName, pwd:$scope.txtPassword}; $http.post("http://localhost/yii2-angular-seed-master

YII2 Redirect to backend after user registration from frontend

十年热恋 提交于 2019-12-13 00:48:22
问题 After installation of advance template in yii2, I got a user registration from at the frontend but I want it to redirect to backend after registration. How can that be done??? public function actionSignup() { $model = new SignupForm(); if ($model->load(Yii::$app->request->post())) { if ($user = $model->signup()) { if (Yii::$app->getUser()->login($user)) { return $this->goHome(); // I WANT TO CHANGE THIS TO REDIRECT TO LOCALHOST/MYAPP/BACKEND/WEB } } } return $this->render('signup', [ 'model'

Optional parameter on urlManager rules

十年热恋 提交于 2019-12-12 10:35:30
问题 I used the Yii::app()->request->getParam() so I can have a friendly url like /listings/amenities/1 . I got 3 actions on my controller that get the parameter $property_id = Yii::app()->request->getParam('property_id') . The two actions amenities and meals are working fine but in the last action photos , the var property_id got a null value. I tried removing the second param on the photos rule and everything works. How should I solve this without removing the second param gallery_id ? Below is

yii query string do not change when click language picker

谁说胖子不能爱 提交于 2019-12-12 03:53:31
问题 Actually My web having language picker, its working nice but some one give redirect url for my webapp. Example http://yii.mywebapp.com/?redirecturl=http://www.google.com It's all working fine... But when click language picker the url will be http://yii.mywebapp.com/?language=en But i need the url not fully changed, i need only the full url following way http://yii.mywebapp.com/?redirectUtl=http://google.com&language=en How can i do this one? 回答1: I assume you simply want to preserve all GET

Yii CLinkPager & urlManager rules

泪湿孤枕 提交于 2019-12-12 01:21:50
问题 I have the following issue: When I press a button in my pagination, CLinkPager generates the link as follows: page/videos/445/?page=2 What I need is something like this: page/videos/445/page/2 Furthermore, I need something like: name/videos/2 where name is url of user_id = 445. I've set some rules in urlManager but they don't quite do the job: For step 1: '<controller:\w+>/<action:\w+>/<id:\d+>/<page:\d+>' => '<controller>/<action>', Any help is appreciated. Thank you in advance! 回答1: Here

Multiple Variables to be passed in URL - Yii2

荒凉一梦 提交于 2019-12-11 13:14:59
问题 I want to generate URL's that can handle multiple parameters as follows. www.mysite.com/index.php/controller/param1/param2/param3/param4/mySlug But still be able to be flexible and pass over less information www.mysite.com/index.php/controller/param1/parama/my_slug_2 We could assume there's always a slug at the end if that makes this easier. Is there anything in the Yii2 urlManager I can implement this. 回答1: Just configure your rule with default values of your params like this: 'urlManager' =

Yii check if homepage

余生颓废 提交于 2019-12-10 04:36:01
问题 Is there a buildin method or property in Yii to check if page is homepage? I know i can use something like this: $controller = Yii::app()->getController(); $isHome = $controller->getAction()->getId() === 'index' ? true : false; Or put it in a method in main controller, but i am looking for something cleaner. Thanks. 回答1: If You want to check the current page, ie action is the default of the current controller.. $controller = Yii::app()->getController(); $isHome = $controller->action->id ===

Email Verification in yii framework

安稳与你 提交于 2019-12-08 04:19:46
问题 I want to verify the user when he click the random generated URL. Give me solution for these two process. 1.What is the URL manager configuration rules for get the hash (string and numbers) from url request? 2.How can I compare the hash value in URL with my hash value in database on Controller/Action? Code for sending email (it's working fine) protected function afterSave() { $activation_url = Yii::app()->createAbsoluteUrl('SignUp/Activate',array('activate_link'=>$this->activate_link)); Yii:

Yii 2 static pages

孤街醉人 提交于 2019-12-07 19:44:36
问题 I can't show static pages. Try do it as described in doc here - http://stuff.cebe.cc/yii2-guide.pdf (on page 100) but when I enable prettyurl, it doesn't work. Added in urlManager rules: 'urlManager' => array( 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => array( '' => 'site/index', 'login' => 'site/login', 'contacts' => 'site/contact', '<view:(break)>'=>'/site/page?&view=<view>', ), ), then in SiteController added: public function actions() { return [ ... 'page' => [ 'class

Yii 2 static pages

♀尐吖头ヾ 提交于 2019-12-06 10:50:50
I can't show static pages. Try do it as described in doc here - http://stuff.cebe.cc/yii2-guide.pdf (on page 100) but when I enable prettyurl, it doesn't work. Added in urlManager rules: 'urlManager' => array( 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => array( '' => 'site/index', 'login' => 'site/login', 'contacts' => 'site/contact', '<view:(break)>'=>'/site/page?&view=<view>', ), ), then in SiteController added: public function actions() { return [ ... 'page' => [ 'class'=>'yii\web\ViewAction', ], ]; } And then created views/site/pages/break.php <h1>View static page Break