Class Loading
Permalink
I am developing my concrete site and need to reference some custom classes.
These are to do with a custom shopping cart that I'm building out are are a 'Basket' and 'Product' object.
If we presume that I will house a class per file, what is considered to be the best practice way of loading these files.
1) As models using Loader::model - if so, where should this call be placed?
2) Using good old require() or include()?
I could really do with some prods in the right direction here so any help would be appreciated.
Regards,
Dan.
These are to do with a custom shopping cart that I'm building out are are a 'Basket' and 'Product' object.
If we presume that I will house a class per file, what is considered to be the best practice way of loading these files.
1) As models using Loader::model - if so, where should this call be placed?
2) Using good old require() or include()?
I could really do with some prods in the right direction here so any help would be appreciated.
Regards,
Dan.
Thanks Tony.
I'm a little green still with PHP and Concrete so I was also after a little best practice.
Typically, do you need to include a Loader::model() call in every file where you use that object or is there a better way with less repetition?
Kind regards,
Dan
I'm a little green still with PHP and Concrete so I was also after a little best practice.
Typically, do you need to include a Loader::model() call in every file where you use that object or is there a better way with less repetition?
Kind regards,
Dan
just like the require or include, you just need to call it once, and prior to where you use the class. You may want to include it in different places depending on how often you need that class. If you need it in multiple places throughout a script, then you can stick it above the start of the page controller.
Many thanks again.
Makes sense.
Makes sense.
then use Loader::model('your_class_file_name'); to load it.