• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Lack of interest Formatter_Base Workflows

xf_phantom

Well-known member
#1
It would be great, if the renderMethods from the formatter (renderTagAttach, renderTagCode,..) wouldn't return the rendered template.
It's impossible to change the used templatename or add own variables to the template without overwriting the complete method. (=> addon conflics)
 
Last edited:

xf_phantom

Well-known member
#2
A quick solution would be a simple wrapper function like
PHP:
  protected function _getRenderedTemplate($templateName,array $params){
  $template = $this->_view->createTemplateObject($templateName, $params);
  return $template->render();
  }

  public function renderTagFoo(array $tag, array $rendererStates){

  $viewParams = array(
  'foo' =>1
  );
  return $this->_getRenderedTemplate('foo',$viewParams);
  }
then addons would have access to the templatename and variables

PHP:
  protected function _getRenderedTemplate($templateName,array $params){

  if (XenForo_Application::isRegistered('myuniquekey')){
  $params += XenForo_Application::get('myuniquekey');
  }
  return parent::_getRenderedTemplate($templateName, $params);
  }

  public function renderTagFoo(array $tag, array $rendererStates){
  if (foo()){
  XenForo_Application::set('myuniquekey',array('foo' => 'baz'));
  }
  return parent::renderTagFoo($tag,$rendererStates);
  }