I am using cakephp 3 and first time using it.I found that I can make controller only in \src\Controller. Here I have put all front end related files. Now I want to make seperate Admin section front end. Please guide how I can do it.
You may want to look at prefixed routing:
http://book.cakephp.org/3.0/en/development/routing.html#prefix-routing
Create a folder inside src/Controller eg src/Controlelr/Admin/. Then you can create a controller src/Controller/Admin/UsersController.php and the view file src/Template/Admin/Users/edit.ctp.
Related
I have a specific folder containing ViewerJS that I want to bypass without using .htaccess
The path I want to work is /ViewerJS/#/files/viewfile/version where version is some integer.
The action viewerJS is not defined in AppController
Error: Create AppController::viewerJS() in file: src/Controller/AppController.php.
Is there any way to achieve this using CakePHP routing? I have managed to get this working before with .htaccess but would much prefer a native CakePHP way.
It's really just a way to tell CakePHP to not try to find a controller etc and just treat it as a direct link.
For our project we've been using a lot of subdomains, but for one particular section we just use a redirect that sends the user of a specific type from the normal dashboard at /dashboard to /manager/dashboard.
This has been in place for months and works, but now in an element within our view we're trying to load some scripts using the HTMLHelper, but it's appending the /manager to the URL.
How can I have it just access the webroot version at
/js/path
instead of
/manager/js/path
using a generic element that is used throughout our application in different subdomains like it doesn't now (with the exception of /manager/*?
Try adding
Configure::write('App.jsBaseUrl','js/');
to your bootstrap.php file.
Alternatively, if you provide the full path to the .js file (starting with a leading /), CakePHP will ignore whatever App.jsBaseUrl holds, and will render the correct path.
I have a form that I am aiming to submit to paypal payment.
I have tried several options like the Paypal API and the like but I can't seem to get the hang of it since the requirement of what I am doing is pretty simple.
Right now I have a form and I am using Webforms to build it. I am well aware that webforms has its default value for action attribute which is not so easy to alter.
Also, the names for the inputs appear to be something like:
name="submitted[last_name]"
To be direct, I would like to change the actions url of the webform and then the field names from to simply name="last_name"
Is there a simple way to do it? If there is, I would appreciate your suggestion.
Also, if what I assume based on my reading that it is not possible, I have read in this question (Using Hook_form_alter on webform submitted values) that I can create a custom module based on webform and make the changes there. The problem is that I am new to drupal and I am still trying to understand how to make things work and I have no idea how to start or create the custom module based on webforms. Is it just simply copying the whole files in webforms then replace all occurences of webforms to my custom module name?
You dont create a module from webforms, instead the usual practice is to hook in to specific form from another module.
Basicly you need 1 folder and 2 files in there, eg mymodule folder and mymodule.info + mymodule.module . Good place to place those would be sites/all/modules/custom/ under your installation directory.
Read the description about .info file at https://www.drupal.org/node/542202
You can connect to webforms in many ways but the standard way in most form tampering cases start with hook_form_alter. Your module could start with something like this
<?php
function mymodule_form_alter(&$form, &$form_state, $form_id){
/* find and tamper with $form here
install devel and then uncomment the following */
//dpm($form);
}
I have successfully created a static website using cakephp to create the static html files using the console.
However, what I want to do now is have a console script that can create multiple websites from the same shared data, with each website using data that is unique to it, but sharing the db as a source.
So, how do I set up the app folder in relation to each website? Do I need a separate installation of cakephp for each site? Or can I have a shared App folder in cgi-bin or something like that?
Thanks
You can share the CakePHP core between multiple apps, however you will need a separate 'app' folder for each website (with the appropriate structure). See this question for more details. Essentially you will need to modify the index.php file in each app/webroot folder to point to the CakePHP core. I use this technique and it's much easier to maintain with only one core as opposed to a whole separate installation of Cake for each site.
I am new to Cake PHP, in regular PHP I had a index.php and for any bad url tried it would just show home. In Cake, I am switching an old PHP and HTML website to use Cake PHP. I already successfully converted one page :(. Which is good but that page is just about_us. I have not done Home (which would be index.php). So here is my scenario
I created all the controllers and models with no code in it except for this one page that gets a bunch of products,but I have the following questions as I do not understand CakePHP documentation:
1) How can I set up an index.php page and where should I put it and Actually this page needs to grab something from the db too. Should it go under views/pages? (i am not sure)
2) Also how do i retrieve parameters in Cake PHP? i used to have index.php?name=blah and just pull name in. I am not too clear on how the cake website says to do it.. you just add the parameter after a /index/2 for example? How come?.
Thank you
I think cake is quite well-documented. You just didn't take enough time to read the book.
1) If you want to create a 'Home' page, it doesn't have to be an 'index.php' file.
(cake has some index.php file to call the bootstrap and dispatch logic and don't mess with them)
You can
- create a view (some .ctp file), put it to /app/View/Pages/ so you can use the url '/pages/' to access the page. Or you can edit /app/Config/route.php file to connect the page to whatever path you want
- create a normal controller/action/view (if you need to grab something from the db so you should have some models, your controller will call the models and pass data to the view). You can edit /app/Config/route.php to connect the page with your path.
Cake is convention-over-configuration. But you should understand both the convention and the configuration. Read the book. Learn more about MVC, about cake's convention and mechanism.
2) You can retrieve the parameter from controller or view (you should do it in the controller) by using $this->param or $this->passedArgs. There are named ones (e.g: profile/name:john) and unnamed ones (e.g: profile/john).