createTemplateObject vs new XenForo_Template

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
What is the "clean" way, to create templates and use them in the code & at template hooks?

ATM i'm using:
PHP:
 public static function getFooterTemplate() {
        $template = new XenForo_Template_Public('Foo', array());
        return $template->render();
    }
to return the template which i'm adding at an template hook and
PHP:
   public static function showPhraseOptions(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit) {
        return $view->createTemplateObject('ragtek_Foo_Option', array(
            'preparedOption' => $preparedOption,
        ));
    }
to create a "option" for the acp options.

Is this ok, or should i use other classes / methods for this?

thx
 
If you can guarantee the type of object you want, it doesn't strictly matter. Though IIRC, createTemplateObject registers all of the default stuff for you as well. You don't get that if you create it directly.
 
ok perfect:)


createTemplateObject registers all of the default stuff for you as well. You don't get that if you create it directly.
What's the default stuff?
The user variables, page_container, etc.. or something different?
 
What's the default stuff?
The user variables, page_container, etc.. or something different?
Visitor, options, server stuff, etc. Easiest to look at $this->_defaultTemplateParams in the various Dependencies objects.
 
Top Bottom