开发者

Kohana 3.1: Calling a controller from within another; not returning data

开发者 https://www.devze.com 2023-02-26 13:37 出处:网络
I just can\'t seem to get my head wrapped around this... I have a few questions, please bear with me! :)

I just can't seem to get my head wrapped around this... I have a few questions, please bear with me! :)

First, the se开发者_运维知识库tup:

I have a controller (controllerA) which extends Controller_Template. Inside controllerA's template view I have jQuery tabs which AJAX-loads another controller (controllerB). And then I have a "core" controller which contains functions that I reuse within other controllers (well, I would LIKE TO anyway).

Now for my questions:

1. Is it okay (best practice) to be loading the jQuery tab contents like I mentioned above, with:

<li><a href="/controller">test</a></li>?

2. In JS and PHP I've always had a 'core' file for reusable code. Is there a better alternative to doing it this way? Should I instead have my core extend Controller and then extend all my controllers off of that? I'm concerned about the overhead though.

3. Last, if I call the core with Request::factory()->execute()->response(), I get nothing back unless I use something like die($data) instead of return $data it. But if I call that function from within another in the core, it won't work. How can I make it work across the board?

Thanks for your help, as always!

Brian


  1. Use reverse routing to generate project URIs. Or you will modify all of your views after changing in routing rules.
  2. Extend Controller_Template in your basic controller class - it will be parent class for all other controllers.
  3. Request::factory()->execute()->response() returns string, so you need at least echo. And dont forget to set $this->request->response in your ajax method.
0

精彩评论

暂无评论...
验证码 换一张
取 消