-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Working Option] Controllerless URLs - mydomain.com/page #704
Comments
The index method is called automatically when you call something like domain.tld/contact. |
@Dominic28 I am not quite sure what you mean? All I am doing is adding methods to the IndexController to render the views in which I would like 'index/' to be hidden...Can you explain a bit how this is 'out of the box'? |
Ah, I see you don't want to use a controller. But it would be possible to do this with controllers and without changes to the core of huge. Can you give me an usecase for your solution? |
@Dominic28 Actually, I do (and am) using It is a legibility and ease of remembering concern I had and wanted to implement. I surely am cool with other controller names showing up in the url as these are unique sections and make users feel more comfortable knowing where they are...like When it comes to pages like While being new to the idea of using the mvc, I wanted to make sure that all my pages are rendered via a controller so I have access to all the functions within that app, yet wanted to segregate a set of pages to show at the base url. The above script recognizes |
Ok I got that :) The script itself calls index automatically. |
@Dominic28 Gotcha! I had considered doing that too but I thought it would get cumbersome if I had a lot of pages. Keeping all the pages I want to show up like that within one controller and one view folder seemed like the way to go :) |
Hey, this is indeed an interesting feature, but I think it's too much work, this will need some rework of the core and a lot of testing, I don't have the time to do this so please let's close this ticket and put it on the "potential features" list in the readme. |
i got a problem, with this! |
pfff... you must read the code carefully according:
when you create a controller called news
when you surf the internet the php loads the news controller and the default index function. if you want to send an argument to the index function you must load from the browser if you want to send arguments to another function called articles and the controller
|
Just wanted to throw something out here....
This is for those of you that want
mydomain.com/page
instead of
mydomain.com/index/page
(no controller displayed)The great thing is that everything is still kept inside the framework and still uses controllers and actions to render everything. And even better, 404 page detection works as expected.
It is completely non intrusive to the framework and only one function in one file needs to modified.
The default controller, which we get from
Config::get('DEFAULT_CONTROLLER')
, is the only one that will hide the controller name when usingmydomain.com/page
yet still works normal when givenmydomain.com/default_controller/page
...like I said, non intrusive :)The logic simplified
mydomain.com
acts like normalindex/index
ordefault_controller/default_action
mydomain.com/login/showProfile
again acts like normallogin/showProfile
orgiven_controller/given_action
mydomain.com/page
this is the good stuff/page
is actuallyindex/page
ordefault_controller/given_action
Here is the script which replaces the current
in the
core/application.php
file.Take some time to look through it...and let me know your thoughts or questions! You can easily give it a try as well, just replace the function and visit a page rendered by and action in your default controller like
mydomain.com/action
I should note that given controller names will always take precedence over page name, this is a must!
ie. if 'dashoard' is a controller and also page name, and you type
mydomain.com/dashboard
the result will bemydomain.com/dashboard/default_action
so no worries there!The text was updated successfully, but these errors were encountered: