Basics

class MyClass extends ContaoClass
{
  protected $variable;

  // generate is always executed
  protected function generate()
  {
  }

  // compile is only executed on frontend
  protected function compile()
  {
  }
}

 

Contentelement mit FE und BE Template

class MyContentElement extends ContentElement
{
  protected $strTemplate = 'ce_my_html_template';

  protected $objContent

  // generate is always executed
  protected function generate()
  {
    $ID = 1;
    $this->objContent = $this->Database->prepare("SQL REQUEST")->execute($ID);

    // Create BE wildcard
    if(TL_MODE == 'BE')
    {
      // Create BE wildcard template object
      $objTemplate = new BackendTemplate('be_wildcard');

      $objTemplate->wildcard = '### WILDCARD TEXT ###';
      $objTemplate->title = 'Entry title (bold)';
      $objTemplate->id = 'ID of module (optional)';
      $objTemplate->link = 'link to module (optional)';
      $objTemplate->href = 'href for link and ID';

      // Build BE wildcard
      return $objTemplate->parse();
    }

    // Resume default process
    return parent::generate();
  }

  // compile is only executed on frontend
  protected function compile()
  {
    // Generate array for template object
    ...

    // Insert array into template object
    $this->Template->myKey = $myArray
  }
}

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht.