Profiles and Statuses public function addTemplateBit( $tag, $bit, $replacements=array() ) { if( strpos( $bit, 'views/' ) === false ) { $bit = 'views/' . $this-registry-getSetting('view') . '/ templates/' . $bit; } $this-page-addTemplateBit( $tag, $bit, $replacements ); } As mentioned above, we need to take this parameter in the method in the page object; this method also needs to be changed to assign both the template bit and the replacements array with the template tag, and not just assign the template bit with the template tag, as it previously did. This can be achieved by putting the template bit and replacements array. | Profiles and Statuses public function addTemplateBit tag bit replacements array if strpos bit views false bit views . this- registry- getSetting view . templates . bit this- page- addTemplateBit tag bit replacements As mentioned above we need to take this parameter in the method in the page object this method also needs to be changed to assign both the template bit and the replacements array with the template tag and not just assign the template bit with the template tag as it previously did. This can be achieved by putting the template bit and replacements array into an array and assigning them with the template tag in the bits array. This is highlighted in the code below Add a template bit to the page doesnt actually add the content just yet @param String the tag where the template is added @param String the template file name @param Array the replacements array return void public function addTemplateBit tag bit replacements array this- bits tag array template bit replacements replacements Now that we have the additional information being stored where we need it we need to process it when we actually insert the template bit into the page. This simply involves iterating through the tags and performing a simple find and replace on the content of the template bit importantly only on the template bit then placing the content generated into the main template as before. The highlighted code below illustrates the changes Take the template bits from the view and insert them into our page content Updates the pages content return void private function replaceBits ------------------------------------ 172 ------------------------------------ Download from Chapter 5 bits this- page- getBits loop through template bits foreach bits as tag template templateContent file_get_contents template template tags array_keys template replacementsl tagsNew array foreach tags as taga tagsNew . taga . values array_values template replacementsi templateContent str_replace .