[eluser]Yorick Peterse[/eluser]
After a bit of thinking about a way to style all modules without having to define any HTML or PHP in the module view itself, I came up with the following idea.
Each module uses the exact same skeleton. This skeleton file can be seen as a template for each module, but without having to make a new template for each module all modules will simply rely upon the same file.
Whenever a certain module is being loaded it will call this skeleton file, which is stored in the user's template, and load it. The skeleton file will define the structure of the content, PyroCMS will only output the raw content. To clarify my idea I created the following skeleton structure :
Code:
<!-- Module title -->
<h3 id="module_title">{MODULE TITLE}</h3>
Imagine we have a template called "beer_template", and the skeleton file is called "module.php". Our template's file structure could look like the following :
When PyroCMS loads a certain module it will send the array "$modules" to the module.php, this array will contain the data required for the module. It will also send the variable "$module_name" to the module.php file. In a typical scenario your module.php file will look like the following :
Code:
<!-- Module title -->
<h3 id="module_title"><?php echo $module_name; ?></h3>