how to naming the model, view, controller files?

Permalink 2 users found helpful
1. How to naming the model, view, controller files in concrete5 ?
2. How to naming the controller class ?
if i had a single_pages file in my directory path
Dashboard/MyProfile/MyfileA.php

I also created my controller file my directory path
Dashboard/MyProfile/MyfileA.php

How can i give the controller class name ?
3. There is any restriction to naming the models file?
and the directory path should be same ?

anyone could explain it plzzzzzz....

Thanks in advance...

cjramki
View Replies: View Best Answer
bbeng89 replied on at Permalink Reply
bbeng89
Assuming the controller was in /controllers/dashboard/myprofile/myfilea.php (not in a package) you would name your class
DashboardMyProfileMyFileAController


I should also mention that the concrete naming convention is to use underscores in file names. So you would probably want to call the file my_file_a.php. This wouldn't change the name of the controller though.

I don't believe there is any naming requirements for models. If you had a file: models/my_model_a.php you should be able to name the class whatever you want then load it in with

Loader::model('my_model_a');


Hope that helps
cjramki replied on at Permalink Reply
cjramki
if i give the name to my file
/controllers/dashboard/myprofile/myfilea.php

can i use controller class name
DashboardMyProfileMyFileAController
like this?
there is no case sensitive issue in it ?
bbeng89 replied on at Permalink Reply
bbeng89
Yes, that is the class name you would use. It has to be camel cased.
cjramki replied on at Permalink Reply
cjramki
if i use the directory structure like this:
/controllers/Dashboard/MyProfile/MyfileA.php

It my sub directory MyProfile already contains the camel case, and my file name (MyfileA.php) contains the alternate camel case...
In that case how can i use controller class name ?
bbeng89 replied on at Permalink Reply
bbeng89
I don't believe it would let you add two single pages named MyfileA.php and MyFileA.php.

If you had MyfileA.php and my_file_a.php their respective controller names would be:
DashboardMyProfileMyfileaController //this is for MyfileA


And

DashboardMyProfileMyFileAController //this is for my_file_a


Only the underscores are translated to camel case.

While this works, I would recommend you always use the concrete5 convention of naming your files with underscores. It will make life much easier for you.
cjramki replied on at Permalink Reply
cjramki
ok... thanks for your clarification...

i have a little bit doubt in models directory...
if i use my view file in the directory path
/single_pages/Dashboard/Class/Myclass.php


i had a corresponding controller file in the directory path
/controllers/Dashboard/Class/Myclass.php


How to place my corresponding model file...
is there is any restriction in directory path ?

/models/Dashboard/Class/Myclassmodel.php

i should use my directory path like this?
is this necessary ?
Please clear my doubt...
bbeng89 replied on at Permalink Reply
bbeng89
No, you can just have your your model right in the models directory. So
/models/Myclassmodel.php


Then you would do:
Loader::model('Myclassmodel');


However, if it works better for you to put it in a subfolder for organizational purposes you can certainly do that. So if you have
/models/mymodels/Myclassmodel.php


You can load it in with:
Loader::model('mymodels/Myclassmodel');


Does that help?
cjramki replied on at Permalink Reply
cjramki
Thank you for your response...
And two more questions i have...

1. There is any restrictions in naming for class in concrete5 mvc...?
2. In concrete5, they follow any standardized directory structure...?
cjramki replied on at Permalink Best Answer Reply
cjramki
In concrete5, naming for class in controller...

It just read the
class directorysubdirectoryfilenamecontroller

For standardized coding style guideline to understand other developers only they use camel case & give some restrictions to naming the directory and files also for classes...

i got this reference from vektor larsson...
Thanks to vektorlarsson (vlarsson)...
he pointing this link for me...
http://www.concrete5.org/documentation/developers/system/coding-sty...

thanks to you bbeng89 for clear my doubts about models directory and class naming format...
Ricalsin replied on at Permalink Reply
Ricalsin
Crediting yourself with an 'answer' after getting help (which you acknowledged) is not nice nor in keeping with the open source community in which you both belong and benefit.

Please fix.