I have two functions which I want to use in both a controller (which is called in template), and a DataModule.
It's only two functions, instead of duplicating the code, whats/where is the best place to put these two functions?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
I have two functions which I want to use in both a controller (which is called in template), and a DataModule.
It's only two functions, instead of duplicating the code, whats/where is the best place to put these two functions?
Page.php Page_Controller
Not sure what DataModule is but if it extends the Page class then it should be accessible in your other two classes.
See this thread for some solutions: http://www.silverstripe.org/general-questions/show/19136
Thanks for the replies.
I don't feel like the functions belong in the main Page controller - as other controllers don't need these functions.
Maybe I could create a separate class with static functions (or normal).