5095 Posts in 1518 Topics by 1114 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 809 Views |
-
Changing system files safely

22 April 2010 at 8:12pm Last edited: 22 April 2010 8:13pm
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
-
Re: Changing system files safely

23 April 2010 at 8:57pm
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!
-
Re: Changing system files safely

24 April 2010 at 11:33am Last edited: 24 April 2010 7:47pm
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?
-
Re: Changing system files safely

24 April 2010 at 11:37am
Ah there is probably a reference to a self::$breadcrumbs_delimiter on line 43? change it to SiteTree::$breadcrumbs_delimiter.
-
Re: Changing system files safely

24 April 2010 at 7:52pm
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!
| 809 Views | ||
|
Page:
1
|
Go to Top |


