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

Clean way for json responses

Discussion in 'XenForo Development Discussions' started by ragtek, May 11, 2011.

  1. ragtek

    ragtek Guest

    What should i do, if i have a controllermethod, which returns only json data?

    I've seen that xenforo is using "non existing templates for this.

    For example:
    PHP:
    return $this->responseView(
                
    'XenForo_ViewPublic_Member_Find',
                
    'member_autocomplete',
                
    $viewParams
            
    );
    template member_autocomplete doesn't exist, but it's used in the responseView

    i'm doing the same in my add-on, but it's IMHO a strange way^^.
    Is there any way to return this without an pseudo view?
    PHP:
            else {
                return 
    $this->responseView('Ragtek_Invite_ViewAdmin_Index''foo'$user);
            }
            return 
    $this->responseView('Ragtek_Invite_ViewAdmin_Index''foo'$params);
     
  2. Robbo

    Robbo Well-Known Member

    I would say it is there in case a mod or something wants to test for that template, more as a reference thing. In listeners etc.
     
  3. Mike

    Mike XenForo Developer Staff Member

    The template can be used as a hint for the JSON output.

    Or it is simply there if there is need for another view type which would output the template.
     

Share This Page