Hello,
I would like to use a custom class in a template. As far as I could find out, one needs to do the following:
1. Store the custom class in the mysite folder:
mysite/customcode/TestClass.php
Next, Silverstripe should automatically load those classes as far as I understood the help pages:
2. Class itself:
---
class TestClass {
function showMeSomething() {
$output = "I am a test message";
return $output;
}
} // end class TestClass
---
3. Template
I tried many ways:
$showMeSomething
<% control TestClass %>
$showMeSomething
<% end_control %>
---
What am I misunderstanding? How can I run my own classes within templates?
Do I have to attach it to an silverstripe object (extend class) --> what would be the most basic class to extend and how can I access the methods?
Do I need to create a controller class additionally --> how would I access the controller then?
Your help will be very appreciated!
Best wishes, A.