Sometimes it is necessary to create a custom layout file. Other times, you may need to define and set custom variables for use in your template file. This article demonstrates the ability to do both, in hopes to clarify the "Magento XML Magic" that is going on behind the scenes.
It is important to follow the MVC pattern, and keep data in models, logic in controllers, and use the view strictly to echo out data.
This example also shows you how to define a custom layout XML file in your module config, so you can update the layout XML from within your own module.