I have am problem because I have a menu where the links always should point to MyController/MyAction, but the site has other routes that go to the same action, but with more parameters.
Will give me the route but if I am currently on the same action and controller, but with more params these are included in the url as well.
Eg. if I am on the page:
http://localhost/MyWebsite/organizations/p001/departments/vest/employees/chn/MyController/MyAction
the url generated will be the same as above and not:
http://localhost/MyWebsite/MyController/MyAction
as i would like. Any suggestions?
Ahh found out that I could use RouteLink instead...
Related
I am rewriting my yii2 website urls.In my config file i added
'<category_name>-<controller>-<category_id>'=>'<controller>/index'
and in the url i just passed the parameters like
<?=Url::to(['shop/index','category_id'=>1,'category_name'=>'clothes'])?>
And my url comes like
https://example.com/clothes-shop-1
This is what i am getting. But i need something like
https://example.com/clothes-1
for that i just changed the rule like this
'<category_name>-<category_id>'=>'<controller>/index'
But that time rewriting doesn't working.How can i remove the controller name from that url
How does system know, what controller is needed to proceed URL? In first example
'<category_name>-<controller>-<category_id>'=>'<controller>/index'
There is a controller name. In second
'<category_name>-<category_id>'=>'<controller>/index'
No controller name.
So you need to tell it. Try
'<category_name>-<category_id>'=>'shop/index'
This might be a very silly question because I'm new to PHP frameworks. But I have got the concept of MVC framework. But this routing thing is very confusing me.
I created a controller and view for dashboard and set it as default. Then I wanted to check if the user is logged in then send him to the login page if it's not.
So, what I did in the routes is this:
$route['default_controller'] = 'dashboard/index';
$route['login'] = 'login';
But even if I add a thousand more controllers and routes, it still goes to the default i.e the dashboard. This was supposed to work http://localhost/codeigniter/login. I'm very sure I haven't put a redirect-to-dashboard code in the login page.
at first it's important to understand to routing in codeigniter.
The key for understanding is $route['url/path'] = controller/method (or "public function")
So. In your case, you routing to Login controller and index method (or index function...this it interpretation of codeigniter )
If you want to check if is user logged or not, you may try to check for examle session variable inside of called functon. But it depends on your application. But I think that is not good idea to check it in routes.php
Hope it helps you.
The default controller in routes, will be the controller that opens your index or first page.
If your first page is in controller "pages", then that is your default controller. Do not use it for your secure dashboard pages
Your first page should be the index method in the controller. It should look like this
$route['default_controller'] = "pages";
Where pages is your first page controller
I have a problem regarding paging of the custom module. When i click on the next page the it take the url as localhost/magento/fme-support/index/index/url/BC/?p=1, but this url doesn't work properly, the correct URL is localhost/magento/fme-support/category/BC/?p=1.
Please suggest me how and i change this url.
Thanks.
Try making url rewrites off
If it doesn't work there is some issue with your extension you have installed
Check for redirect in your extension
The "index" in the URL means you are calling the index controller of the module.
Magento module URLs work like this
http://magento_installation.com/(storeview)/moduleMame/controllerName/functionName/
I have application that accepts four different types of routes. Keyword link is the link of specific page and keyword user is the user that is the owner of the page.
Custom ActionLink should generate links on page depending on route taken to get there. Those links can be:
http://localhost/SiteEdit/user/link
http://www.domain.com/SiteEdit/user/link
http://user.domain.com/link
http://www.user.com/link
It has to create absolute links, because if relative links are used user can enter the page with http://localhost/SiteEdit/user and the default page will be displayed but if clicked on link it would become http://localhost/SiteEdit/link.
thnx in advance
The following link should help:
http://hanssens.com/2009/asp-net-mvc-subdomain-routing/
Update:
Try this gist: https://gist.github.com/RyannosaurusRex/4145948
How to code or achieve this url like wordpress
for example
http://www.example.com/product/view/my-product-sample
is there way to have this url ? any tips tutorial example thank you guys :)
Well, this is already a valid URL without any alteration, calling the controller product, method view with the argument my-product-sample.
However, I think you are looking for routing.
Example:
$route['product/view/(:any)'] = 'products/view_product/$1';
This route is saying: If user requests
product/view/(something)
give them
products/view_product/(something)
As usual, see the user guide for more information.