Hi all.
First of all, if this is wrong subforum, please move it to correct one. I was unsure where to post it.
This is a specific-case question, but as well a general one. I am new to Silverstripe, coming from being Wordpress developer, using the latest release. I need to create custom menu set, for which I have choosen Heyday Menu Manager
This works ok: I can define custom menu sets, menu items that might not be linked to Pages inside SS installation. All great. Unfortunately, I need a class for each generated item in the loop, which can be based on the MenuTitle. Alas, MenuTitle can contain spaces, so I need to get rid of those before.
My first aim was to modify the MenuItem.php code inside the extension itself, by adding this inside the __get method:
if( $field == 'MenuClass' ) {
return str_replace("\s", '', $this->__get('MenuTitle'));
}
This does work, I get an additional MenuClass property to use inside the loop. Unfortunately, this is not the way I'd like to tackle the issue, since any further update to the extension itself won't be available due to modified base code.
I can just fork the project on Github, add MenuClass (or MenuLabel) inside fields of MenuItem and just work that way, but still this is prone to too much problems in my opinion.
Therefore, I'd like to learn how to add extensions to custom classes, especially ones that call their own children classes inside (MenuManager's MenuSet calls MenuItem internally). Can someone suggest me a way to solve this? I am a little bit overwhelmed by the "magic" that happens behind the scenes in Silverstripe.