Clean way for json responses

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

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);
 
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.
 
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.
 
Top Bottom