For the record this is how I came across the require control structure which I used in the template of my module to add a link to a style sheet. As you will gather from what follows I have very little understanding of how object code works.
What I was trying to achieve was to add a style sheet to my module and I thought that I would be able to achieve this by adding a requirements statement to my module's controller class. In fact I became fixated with trying to do it using this approach. As you will see I never got this to work and had to use the require control structure instead.
Since I could not add a css link through creating my own module from scratch because I could not apparently get the file which contained my template's controller class to be recognised, I decided to download from the internet a pre-built module, insert an exit statement at the top of the file containing the module's controller class and see if the browsed page got aborted early. I thought this was a way in which I could detect if the file was recognised and its contents loaded. I now have serious doubts about this test. Anyway, after downloading various templates to achieve this I eventually found a simple template in which inserting the exit statement caused the early abort. I then progressively removed files and file content in this downloaded module unitil I got to the minimum code required to cause the early abort and hence recognition of the class file. Essentially what was needed was the following line in the template's config file
Object::add_extension('Page_Controller', 'Helloworld');
and the following line in the file containing my module's controller class
class Helloworld extends Extension {}
At this point I realised that putting an exit statement at the top of the file and checking for an early abort did not appear to test if the file's content was being loaded. I discovered this as follows. After inserting the Object::add_extension statement in the template's config file I got the following error when the page was browsed.
Fatal error: Object::add_extension() - Can't find extension class for "Helloworld" in ...
I then found that I could avoid this error by re-instating a removed class extension statement in the file containing my module's controller class. On doing this, the page aborted early even though the file in which I had placed this statement contained an exit statement at the top. Hence even though the exit statement was placed above the class extension statement, the class extension statement was still being loaded since its presence prevented the fatal error.
OK, so at this point I discovered that placing an exit statement at the top of a file for checking if file content was being loaded was unreliable and in fact useless in this context. It also suggested that the requirements statement which I had placed in the module's controller class may be being reached after all. I then googled silverstripe and requirements to see if I could find more about it and how to use it. I was in fact thinking that I had specified the path wrongly. Perhaps I needed to specify a full path. This googling then directed me to the requirements section under the heading "Reference" in the Silverstripe documentation. On reading this, I found that I could include a css in a template by using the require control structure.
On further investigation of the Silverstripe documentation I found that explanation of the require control structure was really obvious. In fact it is referred to in the Silverstripe documentation under "Topics" and "css".
At this point I still do not know a way of checking if the contents of the file which contains a controller class is being loaded and I am still unable to get the requirements statement to work.
If anyone can offer me pointers or advice on these 2 issues, I would be most grateful.