The Mojavi 3 Book/Tutorials/Decorator Profiling

Prerequisites
Before reading this tutorial, one should introduce themself to the ((Global Templating - The Decorator Pattern Tutorial)(Tutorials)). Before reading this tutorial, one should introduce themself to the ((http://wiki.mojavi.org:81/159.html)(Global Templating Tutorial)).

++ Profiling

++ Profiling

Decorator profiling is a simple idea: Separate your different arrangements of Decorator template, and populators, into scripts that make those calls automatically. Decorator profiling is a simple idea: Separate your different arrangements of Decorator template, and populators, into scripts that make those calls automatically. To begin, let us take a look, evolutionarily, how one might separate the different display modes, or profiles, from the actual views.

++ Stage 1: Hardcode

In this example, a simple example of direct decoration of templates, does it's job. But it fails to provide a simple means for replicating this pattern of decorator/slot population in other Views without a copy/paste. // 1 ka ans kya h?

=Example 1: Hardcoded decorator information=

++ Step 2: Include

The second stage of abstraction is to create a separate script (a separate php file) and directly include it into your Views - eliminating copied code.

=Example 2: Included decorator information=

As you can see, all the decorator calls have been removed, and an include place in their stead. The include file is below:

=Example Profile: Default.profile.php=

++ Step 3: =setProfile=

The last stage, or what I would propose, is to create a simple method that loads our profiles for us, and perhaps provides with a few other utility functions such as

=Example 3: Included decorator information=

++ The =setProfile= Method

Don't be deceived, the =setProfile= method and the include method are, in the end, equivalent. One requires one more function call than the other, but I believe that the simplicity of the =setProfile= makes it superior, along with providing automatic detection of profiles, and automatically searching in the proper directories (The directories that would store profiles, I suppose, would be MO_TEMPLATE_DIR/templates/profiles/).

=Example 4: The setProfile method=

The member variable =$profile= will allow for a check to be run during View's preRenderCheck