I'm using Yii 1.1.15, and am trying to shorted my url's for a module i have. Right now the url are like this
url/alerts/alerts/admin
url/alerts/alerts/create
i'd like to change it to
url/alerts/admin
url/alerts/create
I have this, but doesn't work
'<action:(create|admin)>' => 'alerts/<action>',
Try this :
'alerts/<action:(create|admin)>' => 'alerts/alerts/<action>',
Related
In my project I used an image cropper widget. I setup the widget, that it save in frontend/web/upload. But in backend I save the images to frontend too.
This is working perfect. Then i want to show the image on the backend, if its exist. And i want to reach the frontend.
Thats why i want to set my own aliases in params-local.php file.
But I using vhosts to my webpages and I want to set Aliases to them.
In Yii2 documentation i found an article from aliases, but it wont help me. I mean i tried to use but it wont work.
I tried this:
return [
'aliases' => [
'#front' => 'http://front.mypage.dev',
'#back' => 'http://back.mypage.dev',
],
];
And I also tried this aswell:
Yii::setAlias('#front', 'http://front.mypage.dev');
Yii::setAlias('#back', 'http://back.mypage.dev');
But when i try to echo Yii::getAlias('#front'); it sais
Invalid Parameter – yii\base\InvalidParamException
Invalid path alias: #front
Maybe someone has a solution for this?
Thanks a lot.
Add in backend/config/params.php like:
return [
'front' => 'http://front.mypage.dev',
'back' => 'http://back.mypage.dev',
];
and use it from:
Yii::$app->params['front']
Yii::$app->params['back']
Let me know your thought.
Try this:
Yii::setAlias('#front', 'http://front.mypage.dev');
Yii::setAlias('#back', 'http://back.mypage.dev');
echo Yii::getAlias('#front');
echo Yii::getAlias('#back');
echo Yii::getAlias('#frontend/path/to/file');
echo Yii::getAlias('#backend/path/to/file');
Yii2 Playground
setting-aliases-in-yii2-within-the-app-config-file
In my codeigniter webapp, I'm using multi language site. Default and in english like these:
www.xxx.com (default)
www.xxx.com/en (english)
And I have a controller where I want to re-route specific calls say potato and tomato to vegie like these:
www.xxx.com/potato/param => www.xxx.com/vegie/param
www.xxx.com/tomato/param => www.xxx.com/vegie/param
So far, I have managed to reroute with default language url using like this in my route.php:
$route['potato/(.+)$'] = 'vegie/$1';
$route['tomato/(.+)$'] = 'vegie/$1';
But I doesn't work for the english site. I did like this, and not working:
$route['en/potato/(.+)$'] = 'en/vegie/$1';
$route['en/tomato/(.+)$'] = 'en/vegie/$1';
Anyone can help me for this? Thanks.
First, create new function to manage the english version, ex: function vegie_en()
then route to it
$route['en/potato/(:any)'] = 'vegie_en/$1';
I have found the problem. I have this in my route.php which makes it rerouting wrongly if there's prefix en/:
$route['en/(.+)$'] = '$1';
I moved this to the end of the route.php and it working very fine now.
I had faced same problem in my project. I fixed it by removing the 'en' and put $2 as for dynamic value.
So in your case, this will work.Please try this given below code.
$route['en/potato/(.+)$'] = 'vegie/$2';
$route['en/tomato/(.+)$'] = 'vegie/$2';
I have implemented project using Yii framework. URL manager works fine but. i need to change the URL text. it could be shown domain name after the category name. ie my project URL is kitchenking.com. After the domain name my category name should be display.
ie kitchenking.com/Thanksgiving. But my project url display like this i shows follow:
http://kitchenking.com/recipe/index1/name/Thanksgiving
i did my config file shows following. please suggest me where needs to change the code.
'Home'=>'site/index',
//'cuisine'=>'recipe/index3',
'cuisine/<name:\w+>/<id:\d+>/'=>'recipe/index3',
'holidays/<name:\w+>/<id:\d+>/'=>'recipe/index1',
'calories/<name:\w+>/<id:\d+>/'=>'recipe/index2',
'recipeshow/<name:\w+>/<id:\d+>/'=>'recipe/recipeshow',
//'recipeshow'=>'recipe/recipeshow',
'recipeshow/<name:\w+>/<id:\d+>/'=>'index.php/recipe/course',
above code. i wants to be change like this. recipe/index3 instead cuisine,
recipe/index2 instead holidays,
In UrlManager modify the rules as follows :-
'urlManager' => array(
'rules' => array(
'cuisine' => 'recipe/index3',
'holidays' => 'recipe/index3',
)
)
Is there any way to find page by id in layout file. I'm currently using
$this->fuel->pages->find(5)
But its not working. I'm getting following error message
Plugin module can not be found, maybe you forgot to bind it if it's a
custom plugin ?
You have to use an array to pass parameters in the method and you can use the find_one.
$this->fuel->pages->find_one(array('where' => array('id' => 5)))
we're using codeigniter framework to build application, but we're facing problem to configure '$route' to send correct request.
we just need to setup these route properly.
How i access category:
Category: http://localhost/codeigniter/category/'category-name'/
$route['category/(:any)'] = 'category/index/$1';
Category Post List By Alphabet:
Category Page by List: http://localhost/codeigniter/category/'category-name'/list/'A'/
$route['category/(:any)/lists/(:any)/'] = 'category/lists/$1';
How i access pages:
Page: http://localhost/codeigniter/page/'category-name'/'page-name'/
$route['page/(:any)'] = 'page/index/$1/$2';
we're using rotue something like that, maybe we have problem in it, please check these and let me know how to fix that.
In our codeingiter installation we are using 'codeigniter' dir, 'category' AND 'page' are controllers. in single quotes we are sending values.
Try like
$route['page/(:any)/(:any)'] = 'page/index/$1/$2';
And
$route['category/(:any)/lists/(:any)/'] = 'category/lists/$1/$2';// But Iam not sure
$route['category/(:any)'] = 'category/index/$1';