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.

Customising the CMS

Changing system files safely


Reply

5 Posts   992 Views

Avatar
polyfragmentiert

22 April 2010 at 8:12pm (Last edited: 22 April 2010 8:13pm), Community Member, 4 Posts

Hello,

I'm currently playing around with SilverStripe 2.4 rc1 and will freely admit I'm not a hot-shot PHP/OOP/MVC programmer (yet). I know the basic procedural stuff, but would like to learn.

I'd like to know how to tweak system files like "SiteTree.php" without losing the changed funtionality on a new install or upgrade? In my case, I'd like to change how links in breadcrumbs are rendered.

Some nice dude from IRC gave me a hint yesterday, but I forgot the details. I think it involved specifying a new SiteTree.php in _config.php?

Any hints appreciated

Cheers,

- Thorsten

Avatar
Willr

23 April 2010 at 8:57pm Forum Moderator, 5511 Posts

Hi Thorsten and Welcome to the Forums.

I'd like to know how to tweak system files like "SiteTree.php" without losing the changed funtionality on a new install or upgrade? In my case, I'd like to change how links in breadcrumbs are rendered.

In most cases you can extend SS without ever touching the core files. This is one of the things we try quite hard to maintain and improve as editing core files is annoying, hard to maintain and risky.

In your case of customizing the breadcrumbs - you can copy the function from SiteTree.php to your Page.php file in mysite/code. Paste it into your Page_Controller then edit away!.

You can still use the standard $Breadcrumbs template tag. All this does is call the one on your Page before SiteTree and as long as all your Pages on the site extend Page and Page_Controller you should be fine!

Avatar
polyfragmentiert

24 April 2010 at 11:33am (Last edited: 24 April 2010 7:47pm), Community Member, 4 Posts

Hi Willr,

thanks for the warm welcome and your suggestion!

When I insert the Breadcrumbs() function into the Page_Controller I get the following error:

Fatal error: Access to undeclared static property: Page_Controller::$breadcrumbs_delimiter in C:\wamp\www\silverstripe\mysite\code\Page.php on line 43

Added:

return implode(self::$breadcrumbs_delimiter, array_reverse($parts));

I haven't touched any other code yet, what could be the problem here?

Avatar
Willr

24 April 2010 at 11:37am Forum Moderator, 5511 Posts

Ah there is probably a reference to a self::$breadcrumbs_delimiter on line 43? change it to SiteTree::$breadcrumbs_delimiter.

Avatar
polyfragmentiert

24 April 2010 at 7:52pm Community Member, 4 Posts

I added in the line in question in my earlier post, thanks for the indirect reminder and your successful guesswork!

It works now! :) Thanks a lot!