Web Oriented Object Framework

User Guide (Version 0.5b4)

Woof!
User Guide (Version 0.5b4)

Extending the default layout

In addition to customizing the size and positions of various sections in the default layout, you may also extend it by defining new sections within any of the predefined sections.

For example, suppose the top part of the main section for every page is a link showing Google's search box. We could hard code the link in the template file for the main section for every controller and action. However, this makes it harder if we want to switch to the Bing search box at some future point when Microsoft throws a five-dollar bill at us. A better way would be to define a single main template for the controller and then within it define a new page section to contain the actual content.

Assuming the controller is mycontroller, create a common main page section containing the following:

<div class='search_box'>
  ...some javascript for the search box...
</div>
% if {[page fetch content data]} {
  $data
% }

In effect we have now defined a new page section called content that will be retrieved using the same search algorithm used for retrieving predefined sections. To render the main section for the myaction in the controller, Woof! will look for mycontroller-myaction-main.wtf. Upon not finding this file, it will look for mycontroller-main.wtf and find it containing the above content. When encountering the page fetch command, it will look for mycontroller-myaction-content.wtf and insert it in the appropriate place.

The advantage of this approach is that should we desire to make any changes to the search box, or even move it below the real content, we only need to modify the one single file above.