/wtv2/office - Office Modules

This directory contains the code for the old default backend modules of WebTemplate.

Each module is contained in a subdirectory of this folder. The layout for a modules folders is:

When a module is accessed in the office, all the code in the code directory will be included. Usually there will only be one file in the code directory (ModuleName.php). It is the responsibility of this file to determine which template will be displayed.

Example:

code/SampleModule.php

<?php

class SampleModule extends WTModule 
{
  function init() 
  {
    // register content.wt as the default template
    $this->registerTemplate("content.wt", "Content", true);

    // register another template "otherTemplate.wt"
    $this->registerTemplate("otherTemplate.wt", "Other Template");
  }


  function preRender() 
  {
    $cmd = $GLOBALS["WT"]->getRequestValue("cmd");
    $module = $GLOBALS["WT"]->getRequestValue("module");
    $page = $GLOBALS["WT"]->getRequestValue("page");

    // if a request comes in for the "other" page, display the "Other Template"
    switch($page) {
      case "other":
        $this->m_template = "Other Template";
        break;
    }
  }

  function preEvaluateTemplate($template, &$templateData, $args) {
    $cmd = $GLOBALS["WT"]->getRequestValue("cmd");
    $module = $GLOBALS["WT"]->getRequestValue("module");
  }
}

?>
 
templates/content.wt:
 
<p>This is the Sample Module<br/><br/>
<a href="?module=[wt:wt.request.module]&page=other">Click here</a> for the other template
</p>
 
templates/otherTemplate.wt:
 
<p>This is the Other Template<br/><br/>
<a href="?module=[wt:wt.request.module]">Click Here</a> for the default page
</p>