There are certain concepts that, while not necessarily unique to Bonfire, will be important for you to understand to get the most out of Bonfire.
|Important Concepts||There are certain concepts that, while not necessarily unique to Bonfire, will be important for you to understand to get the most out of Bonfire.|
|Contexts||A Context is an area of similar responsibility, like Settings, Reports or Developer Tools.|
|Modules||Modules are collections of MVC triads that contain functionality limited to one specific area, like Pages or Database Tools.|
|HMVC||Heirarchical Models Views and Controllers, or HMVC, provides a powerful new way to work build your web pages.|
A Context is an area of similar responsibility, like Settings, Reports or Developer Tools. The Contexts form the main navigation through Bonfire’s admin area. There are three contexts that are required (as well as a Public Context), and you can create as many additional Contexts as you desire.
Learn more about working with Contexts Overview.
Modules are collections of MVC triads that contain functionality limited to one specific area, like Pages or Database Tools. They are the heart of Bonfire and you will spend most of your time developing new modules. Modules can contain their Models, Controllers, Views, Helpers, Libraries, config files, language files and even styles and scripts.
Modules are covered in more detail in Modules Overview.
Heirarchical Models Views and Controllers, or HMVC, provides a powerful new way to work build your web pages. It keeps functionality packaged into discreet modules and provides a simple way to include them in your views.
In a typical CodeIgniter workflow, your Controller would be responsible for pulling the data from various models and libraries and adding them to a $data array that is sent to the view. This means that the view becomes larger and more difficult to maintain, as the amount of information on your page grows. Using HMVC, you can delegate the display of that information to the module it belongs to.
Imagine that you’re building a web site for a newspaper. The front page would have a number of different types of content, including stories and advertising. You would create a Stories module that contains all of your admin power, but then would also create your public context (simply a controller called stories) that contains methods to display the featured story and recent stories.
In your site’s index file, you would use the modules::run method to display the results of the story methods.
<?php echo modules::run('stories/stories/render_featured' 1) ?>
In this example, the stories module, stories controller, render_featured() method is being called. Within that method, it pulls the data from the database, and then renders a view. This view is cached by PHP and returned to the modules::run() method. The end result is that your main index file is clean, while the contents of the stories render_feature() method is inserted at the proper location in the index file.
You would also create an Advertising module that has a public controller responsible for displaying the different blocks of advertising. You might call it using the render ad block() method in your site’s index page.
<?php echo modules::run('advertising/advertising/render_ad_block', 'block_type') ?>
HMVC allows for a very clean way of working and keeping your information separated and easily maintainable.
For more details on HMVC, refer to the author’s original documentation.