I am creating content management system for my project. I have created models and controllers in protected folder for admin-panel. It is working fine in admin panel but for accessing same controllers and models only changing the view for user-panel but I got the error of page not exist. I search that question here but i am satisfied with answer my issue remains the same. Thanks in advance.
double check your route file and see if the link or the page that is missing is added to your route file,
,
your route file depends on what mvc framework you are using,
Use aliases to achieve this, i suppose both the folders are independent applications.
http://www.yiiframework.com/doc-2.0/guide-concept-aliases.html
Create the alias for "admin-panel" in common/config/aliases.php
Yii::setAlias('admin-panel', dirname(dirname(__DIR__)) . '/admin-panel');
and while rendering the page in user-panel give the view path using alias
return $this->render("#admin-panel/views/controllername/file");**
**or whatever your folder structure is
Related
I was practicing to work with Yii2 based on the tutorial in this link : http://www.yiiframework.com/doc-2.0/guide-start-databases.html
I am using Advanced Application
These are the files that i have created:
frontend/models/Country.php
frontend/controllers/CountryController.php
frontend/views/country/index.php
now when i try to access it using index.php?r=country/index i get 404 not found error.
But if i move the actionIndex of CountryController to SiteCountroller and rename it to actionCountry and also move my view file inside site folder (and of course change the name of index.php to country.php) then i can successfully see the list of countries using the address index.php?r=site/country
Any ideas about the 404 not found error?
Examples in tutorial are for basic application and contains app\ in namespaces declaration. And you are using advanced application so for frontend it should begin with frontend\ (see for example SiteController in advanced application).
I think this is the reason since you said that file content is exactly the same, you didn't change default configuration and checked folders, files and classes for correct names.
I have a project where I need to mask the url.
Before: example.com/pogi/ako/
After: example.com/ako/
The application is created using codeigniter. Thoug the one found on the sub-directory have another webservice created with codeigniter as well. I tried doing some configurations I know with .htaccess and httpd.conf, but I was not able to make it run.
In the file "application/config/routes.php" add the line:
$route['ako'] = 'pogi/ako';
This will make is so that any request that comes through to example.com/ako will actually go to example.com/pogi/ako but it won't look like that.
Hope this helps!
You may want to remember how Codeigniter Handles URLs, you mentiond Sub Directory in your Question which also is Codeigniter Based Web Service !
When you are Running first Codeigniter App it will Catch your requested Url and get the related Controller and it's Method to Handle it !
Your Controllers can be nested in Sub Directory too ! also as #Ross Mentioned in his answer, this behavior can be override using Routes !
I have a big doubt building the structure of my application using Laravel because I want to use two controllers using the same folder, for example, this is my current structure:
Folder structure
app/views/dashboard.blade.php
app/views/settings.blade.php
app/views/business/dashboard.blade.php
app/views/business/settings.blade.php
Routes.php
Route::get('/user/dashboard','HomeController#dashboard');
Route::get('/user/settings','HomeController#settings');
Route::post('/user/login','UserStandardController#login');
Route::post('/user/logout','UserStandardController#logout');
Route::get('/business/dashboard','BusinessController#dashboard');
Route::get('/business/settings','BusinessController#settings');
Route::controller('/','HomeController');
Route::resource('/business','BusinessController');
Route::resource('/','UserStandardController');
Route::resource('/','UserBusinessController');
Basically:
HomeController is used for loading the views for the standard user.
BusinessController is used for loading the views for the business user.
UserStandardController and UserBusinessController are used for the actions for those accounts, for example: login, logout, update settings, update profile, etc.
But the problem is when I try to load mysite.com/user/login, laravel says "Method [login]" doesn't exists and is obviously because in HomeController doesn't exists the login method but exists in UserStandardController... but I don't know how to do this.
I hope you can help me!
You only have POST route for /user/login, you need to have Route::get also.
You have to create a login method in UserStandardController class for this error to go away.
As /user/login is searching for a login method in UserStandardController.
I hope this helps.
I need some help. I'm new to laravel and I'm experiencing some weird things.
I have a "users" resource inside views/users. Inside it are index.blade.php andcreate.blade.php.
My app url is http://laravel.dev/ so basically if I need to access the "Create Users" form I will go to http://laravel.dev/users/create the view loads fine but when I tried to click a link on my navbar it automatically adds "users" on the url even if there's no "users" in the nav url link. Example.
Dashboard
When I click it, it will add "users" in the beginning of the url automatically making it users/dashboard and as expected I get a 404.
My navbar is being loaded from other php file in my header.php
Here's my route
/*Route for Users*/
Route::resource('users', 'UsersController');
I would suspect that you are using page relative links, correct? In a nav I've always found it best to use root specific links so "/dashboard" vs. "dashboard."
If you are new to Larvel you may want to take a serious look at the rooting options before going to far into your project just because if you decided to go a different way, namely routing through the controllers (http://laravel.com/docs/controllers#resource-controllers) With a large app it can be a far better way to go, but the refactoring can be tough after to you have a complex enough app to justify it.
I downloaded the latest version of cakephp. I use cake command line tool for creating a sample project. However, I edited the view file with corresponding controller file but the edited content does not appear. I try a test by rename the view folder of application but the view displayed normally. I think that the view I edited is not the true view cakephp use for rendering.
P/S: the view folder is under the application folder.
-- Edited
The file I edited is: C:\Program Files\xampp\htdocs\cakephp\myapp\views\posts\index.ctp
And the link I was trying to view is http://localhost/cakephp/myapp/posts/index . The edited content does not appear. I also tried an absurd test by deleting the view folder but the webpage display normally. I really don't understand what happened.
You do not need to construct the view again when you delete the var scaffold.
Make a index action (method) in the post controller and then your app get your index view.
Please read the cakephp docs for further information.