Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Changing system files safely

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 971 Views
  • polyfragmentiert
    Avatar
    Community Member
    4 Posts

    Changing system files safely Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Changing system files safely Link to this post

    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!

  • polyfragmentiert
    Avatar
    Community Member
    4 Posts

    Re: Changing system files safely Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: Changing system files safely Link to this post

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

  • polyfragmentiert
    Avatar
    Community Member
    4 Posts

    Re: Changing system files safely Link to this post

    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!

    971 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.