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

Unhappy couple: xen:callback and ControllerPublic::action

Discussion in 'XenForo Development Discussions' started by Marcus, Aug 21, 2013.

  1. Marcus

    Marcus Well-Known Member

    I have lots of ControllerPublic::action functions returning their results by template hook, all of which I now translate to xen:callback.

    xen:callback does not like the action parameter, instead I can use return, get, view. When I use the get function and rename my action function to get, functionality as $this->_input->filterSingle gets lost.
    PHP:
    <xen:callback class="My_ControllerPublic_Forum" method="getIndex"></xen:callback>
    PHP:
    class My_ControllerPublic_Forum extends XenForo_ControllerPublic_Abstract
    {
       public function 
    getIndex()
       {
         
    $forumId $this->_input->filterSingle('node_id'XenForo_Input::UINT);
      
    $myVar $forumId*5// for testing obviously
        
    $viewParams = array(
             
    'myVar' => $myVar ,
         );
         
         return 
    $this->responseView(
             
    'My_ViewPublic_My',
             
    'my_sidebar_forum_list',
             
    $viewParams
         
    );
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    xen:callback is not supposed to be used in this way.

    You should be just extending existing controllers.
     
  3. Marcus

    Marcus Well-Known Member

    What do you mean by existing controllers? XenForo_ControllerPublic_Abstract is not fitting into this category?

    What is the easiest and most convenient way to return a template like I try in my first post?
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Marcus likes this.
  5. tyteen4a03

    tyteen4a03 Well-Known Member

    Just wondering, why are you avoiding extending Controllers at all costs? (This is the impression I am getting)
     
  6. Marcus

    Marcus Well-Known Member

    Thanks, that's very important to know :)
     
  7. Marcus

    Marcus Well-Known Member

    I am simply looking for a way to avoid template_post_render to add templates for my addons. This is slowing my test system down for 0.01 seconds, and it only merges my template with the sidebar template on forum_list:
    PHP:
    //template forum_list
         
    $sidebarTemplate 'sidebar_forum_list;
         
         $output = $template->create($sidebarTemplate, $template->getParams());
           
         empty($containerData['
    sidebar']) ? $containerData['sidebar'] = $output : $containerData['sidebar'] .= $output;
     
  8. tyteen4a03

    tyteen4a03 Well-Known Member

    You can't use forum_list as event hint?
     
    Last edited: Aug 21, 2013
  9. Marcus

    Marcus Well-Known Member

    My addon which adds its sidebar template into the existing sidebar on forum_list works great. However I want to avoid adding templates on execution. I want the templates to be compiled within the system before execution. That's why I want to use the template modification system.
     
    Last edited: Aug 21, 2013

Share This Page