views:

32

answers:

1

Hi all,

Can you help me how to develop custom methods in CakePHP framework.

I found this code in stackoverflow, but it's global, it's not "model related".

Can you help me with this?

Thank you in advance!

A: 

If the code is related to the retrieval or 'serving' of data, put it in the appropriate model.

If you are writing code that is going to do something with or without that data, ultimately for display on a webpage, put it in the controller.

If you're manipulating data for display - e.g. looping over an array of results to build a table (see a standard CakePHP index.ctp for an example) or if you're simply echoing data to display or using helpers to build a page, then it goes in the view (.ctp).

This is all well covered in the first three chapters of the book.

Leo