I have created a module in PyroCMS like mymodule and create the front controller songs.
Now I want to set the my routing from
www.example.com/mymodule/songs to www.example.com/songs
Please help me.
Haven't tested this but something like the following should work, assuming you have the URL schema www.example.com/mymodule/songs and www.example.com/mymodule/songs/song_id:
$route['songs'] = 'mymodule/songs';
$route['songs/(:any)'] = 'mymodule/songs/$1';
Depending on your version you could use the routes module.
Something like: foo/(:any) => bar/baz
Related
I just got an issue , i have 2 problems :
I want create a custom route for fast using without copy past code many time. Example Laravel 5 have default Route:resource (...) to make Restful! But i want to make my custom route function , Route:api(...) , Route:xxx(...) ... and I can custom it what I want !
How can I use multi route file ? Example : I can define route in App\User\route.user.php , App\Book\route.book.php .... because now, I can only use route file in route folder default !
I do not understand properly question 1. But for question 2, try this:
Go to app/Providers/RouteServiceProvider.php. Look for the function mapWebRoutes(). The line
require base_path('routes/web.php');
Duplicate it and change so you now have :
require base_path('routes/web.php');
require base_path('app/User/route.user.php');
require base_path('app/Whatever/route.whatever.php');
And laravel will load all routes within those files. Now, I've tested this, it works (Laravel 5.3) but I can't guarantee anything or if there are going to be conflicts with routes (duplicates). But yeah, it works.
I am upgrading a Joomla Website from 1.5 to 2.5 and I have a problem with a custom component which gets the setting params from the JEvents component. The old source tries to get the group names of these settings like this:
$groups = $this->params->getGroups();
But this does not work with Joomla 2.5.
I didn't find useful information on Google, so maybe you can help me out with this.
Thank you very much!
If it's simply the parameters from JEvents that you want to retrieve, then you can use the following:
$app = JFactory::getApplication('site');
$params = $app->getParams('com_events');
$var1 = $params->get('paramName1');
$var2 = $params->get('paramName2');
$var3 = $params->get('paramName3');
Hope this helps
Solved it by myself.
I changed the component input to a Form instead of Parameters and bound the Parameter Data in a JRegistry to the form.
The view works with fieldsets as groups.
I'm trying to make folder in controller folder with exact name like controller in Codeigniter. Is it possible by some trick or something?
Screenshot here: http://i.imgur.com/vrQ1J9V.png
If it will be like
/controllers/manage/manage.php
you should add in /config/routes.php
$route['manage/(.*)'] = "manage/manage/$1";
$route['manage'] = "manage/manage";
There is no problem in using the same name, but it is confusing. The best solution would be to change the name, but you can use just fine.
Remember to use the routes with 'manage/manage/function'.
EDIT
I incorrectly viewed the first time and thought manage.php was outside the manage folder.
It will work, but your URL will just have "manage" twice. You could change the routes config to remove the first "manage", but it will be less confusing and time-consuming to just name manage.php something different.
This is my routes setup code
$route['general/(:any)'] = "videos/filter/$1/1";
$route['general/(:any)/(:num)'] = "videos/filter/$1/1/$2"; //pagination
Following link works fine.
www.example.com/general/latest
But below link doesn't work like what i want
www.example.com/general/latest-trending/5
$route['general/(:any)'] only executes always.
How to solve this issue?
Reverse the order:
$route['general/(:any)/(:num)'] = "videos/filter/$1/1/$2"; //pagination
$route['general/(:any)'] = "videos/filter/$1/1";
You want more specific routes first, because if the shorter one matches first, it will ignore all other routes.
I had my users profile at
www.domain.com/user/username
and moved it at
www.domain.com/username
but this required to add most classes functions into the routes.php file in the config and if i want to add new features to my app i will need to add all the functions into the routes.php file which doesnt sound good practice...
What is the best way that other deal with it on CodeIgniter ?
Perhaps, you can do it the other way round - make a whitelist of usernames that can't be taken (those would be names of your controllers, like admin, contact, etc...) and route anything except the whitelist items.
seems i got the answer
what i did is add the below code for every controller i have
$route['controller'] = "controller";
$route['controller/(:any)'] = "controller/$1";
and this code at the bottom
$route['(:any)'] = "user/$1";