1
votes

I'm new in cakephp.
And I try the amazing feature in this framework, cake bake
I want to customize output in the model, view and controller in cake bake

  1. How to create new file view in baking (view,index,add,edit .ctp) example export_excel.ctp
  2. How to display schema field, in example folder ("C:\xampp\htdocs\cake\lib\Cake\Console\Templates\default\actions\controller_actions") for modified controller output. like "lib\Cake\Console\Templates\default\views\index.ctp" i found this script:
foreach ($fields as $field): //but this code i put in the controller_task not working

Sorry for bad post, my english is bad..

3

3 Answers

0
votes

Question 1 - Do want to be able to create a custom view type using bake? I guess you could extend CakePHP's bake shell, something like this (app/Console/Command/MyBakeShell.php):

App::uses('AppShell', 'Console/Command');
App::uses('BakeShell', 'Console/Command');

class MyBakeShell extends BakeShell {
public function startup() {
        parent::startup();
    }

    // Etc etc, your implementation here...in the main() method I guess you could add a call to new function for generating your custom view
}

Is that what you're after? I Imagine this would be quite fiddly, you may have a use case that justifies the work though.

Question 2 - Didn't really understand this?

0
votes

being a novice myself, I hope I can help you.

When you bake, it creates for you all the model, controller and view. I discovered that by answering the questions about the fields, relationships in tables and helpers it creates all these for you, I suggest you create a mysql db with 2 tables and make relationship between the 2 and start to bake and do this several times to see what things are happening [reading cakephp manual] will help as well of course.

When you understand the relationship between the mvc then you will know you can create your own controller and a view to build extra pages for example.

I had some trouble to understand the plural and others till I found this url about the inflector, I can advice this to you as well. http://inflector.cakephp.org/

If you want to create a new view, you need to create first a new controller. Then create a folder and put in that folder your new view index.ctp

So let's say you want to create a new page on your website called spain, create controller spain manual in folder app/Controller/SpainController.php

 <?php
 App::uses('AppController', 'Controller');
 /**
 * Spain Controller
 *
 */
 class SpainController extends AppController {
public $helpers = array('Html', 'Form');

public function index() {
$this->set('title_for_layout', 'Properties in Spain');
 }
 }
 ?>

Then you create your view in /app/View/Spain/index.ctp

 <!-- View for Spain -->
 <br /><h1 align="center">Put your text here...</h1><br />
 <div align="center"><hr><br />

That's it regards your own view... Not sure if I understand you correct about this export.excel but it seems to me you want to create something what exports data out of your DB. So you start cake bake, 1 controller, select the tables with the data to export and answer the questions. When whole process done, you can modify your view.

Not sure about your other question. Hope this helps.

0
votes

copy paste lib/Cake/console/template to templates/your_name/views/3files

modify 3 files bake to see changes