What I am trying to do is to create a PageHolder page type which can be assigned to any page which contains children. Users would typically click on a PageHolder page in a top level menu which would then display summaries of all pages which that page contains.
I would like to separate out the markup and css for this page type by putting it in a module. I see that Tutorial 2 makes an ArticleHolder page type but does not separate out the code.
If this makes any sense and is possible, is there a simple and clean way of doing this? I would like to keep this as simple and clean as possible. Obviously if this module is not simple, and easy to create and implement, there would be no point in doing this.
Although I think I have now got this sussed, if putting a page type in a module is not a good idea, perhaps someone could advise.
I guess one disadvantage is that separating out the css from layout.css and putting it in a separate file, will increase the number of needed round trips to the server and hence introduce further delay before the user sees the page. As such I think there is a trade off here between modular code and performance. Of course if there was a way in which the content of all the css files could be concatenated after the server receives the initial request and before the browser receives the code, the best of both worlds would be achieved.
Usually a single page doesn't warrant its own module IMHO. But if you like to do that (maybe for easier usage across several sites), then why not?
You're right about the CSS that would create another request to the server... but if it's not a high-traffic site, this shouldn't be an issue. If it turns out to be one, you can still use Requirements::combine_files to combine several CSS files into one.
Your module should have the following file-structure:
code -- folder that contains your code
css -- folder with your css files
templates -- folder with templates required for your module
_config.php -- important. You need this, otherwise SilverStripe won't pick up your code. Can be an empty PHP file
That's it. Create the files (don't forget _config.php) and run dev/build and the framework should pick up your page type from your module.