Reputation: 1
I want to call a .ctp file in one 'Model' and the .ctp file is in another 'View'. Is it possible in cakephp?
Or instead of that should i call that 'Controller' function in my 'Model'?
Upvotes: 0
Views: 722
Reputation: 8069
CakePHP in a nutshell, and the keywords that you might need to search for:
Dispatcher
and Routing
controlling how URL reaches your controller.
Controller
places system logic and controlling individual routing requests from Dispatcher
Component
places logics that can be easily shared by Controller
sModel
is for all the database related queries, manipulation, selections, deletions
Behavior
can be deem as similar to Component
, that provides "mixins" to Models to achieve similar behaviors, such as TreeBehavior
abstract your database tables into parent-child relationship.View
is used by Controller
to render individual pages to the user
Helper
placed shared functionalities to help View render certain stuff. For example, FormHelper
helps you all sort of form rendering, inputs, etc.Place globally shared library in app/Lib
folder so it can be easily accessed through using App::uses('...', 'Lib')
. For example, a Gravatar
library that helps you convert emails to md5-hashed strings. So this can be used everywhere in your app.
vendors
are for those packaged vendor libraries that do not respect MVC, for example, swiftmailer
that helps you send emails. Usually I would abstract them into my Lib
folder for ease.
plugins
are for those baked CakePHP applications found everywhere in the internet.
There are others in-depth stuff that you might be interested in, but these are the most basic stuff that you need to know before using a MVC framework like CakePHP. Check out their docs before diving in.
Upvotes: 1
Reputation: 532
You can't access View (.ctp) in Model, it's against MVC architecture and logic. Just tell us more what do you want to do, maybe you're doing something wrong.
Upvotes: 0