1. 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

Discussion in 'Closed Suggestions' started by xf_phantom, Nov 21, 2013.

  1. xf_phantom

    xf_phantom Well-Known Member

    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: Nov 21, 2013
  2. xf_phantom

    xf_phantom Well-Known Member

    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);
      }
     

Share This Page