Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Replace a core class with my own.


7 Posts   2294 Views


6 March 2009 at 1:29pm Community Member, 164 Posts

I would like to replace a core class with my own without actually editing anything in the saphire folder. Is there a way to make they system load my version of a class instead of the core version?


6 March 2009 at 2:12pm 4085 Posts



7 March 2009 at 6:34am Community Member, 164 Posts

Thank you for your reply.

Where would I put that line of code? Does it go in the Page.php file?


7 March 2009 at 11:10pm (Last edited: 7 March 2009 11:10pm), Forum Moderator, 5511 Posts

no usually you would put that in your mysite/_config.php file


19 March 2009 at 6:30am (Last edited: 19 March 2009 8:13am), Community Member, 164 Posts

I have attempted to replace the Image_Selector class with one of my own so that instead of having options to upload an image from users computer is removed. (I only want CMS users to be able to select from a preselected set of images from a specific folder.) After putting my version of the class in my page.php file I added


to my _config.php file. However SS is still using the original. I read somewhere else on the forums that only some core classes can be replaced with custom ones using the Object::useCustomClass method.

I really just want to override a single function in the Image_Selector class. If I create a new class in page.php that extends Image_Selector, I get an error telling me that Image_Selector class does not exist. I am not very experienced with OOP so I am not sure how to properly overload a function this way as I am guessing that page.php does not inherit the Image_Selector class. If this is the case, then how am I able to overload a function?


7 April 2009 at 11:14pm Community Member, 33 Posts

Think you need to create a new file, with the name of the custom class. I.e.

MyImage extends Image would have a filename of MyImage.php


9 April 2009 at 10:10pm Community Member, 7 Posts

A file MyImage.php must be In what file?