7957 Posts in 1397 Topics by 945 members
|Go to End|
31 August 2010 at 4:04am
I have modified Image_Gallery, Ecommerce and Blog modules php code extensively.
I was wondering what was the best practice for doing so.
For instance I created MyImageGalleryPage.php, that extends ImageGalleryPage.php. That's working fine. But more specifically, I also made changes to ImageGalleryItem.php. Can I create a MyImageGalleryItem.php that extends ImageGalleryItems.php. Will the modified "my" page be called? Will Silverstripe be able to complete the puzzle?
Also, as it stands, both Image Gallery Page and My Image Gallery Page pagetypes show in the CMS in the create dropdown menu. I would like to disable Image Gallery Page. I read somewhere that it was possible, but I cannot find the information again. What is the correct syntax?
31 August 2010 at 4:29am
In general, you should never have to modify the source of a module. If you do, either the module isn't engineered very well, or you're not extending it the right way.
To answer your question about ImageGallery, to get it to talk to your ImageGalleryItem subclass, add:
protected $itemClass = "YourImageGalleryItemSubclass";
To your ImageGalleryPage subclass (MyImageGalleryPage in your case).
To hide the ancestor, you can add:
static $hide_ancestor = "ImageGalleryPage";
Hope this helps.
Silverstripe tutorials, screencasts, tips, and more: http://www.leftandmain.com
|Go to Top|