librelist archives

« back to archive

Map query string to controller method parameter in Kohana 3.2

Map query string to controller method parameter in Kohana 3.2

From:
shiplu
Date:
2012-01-04 @ 22:31
The question is already asked in stackoverflow. Now giving it here, in this
dead list.


I want to setup my route so that url like word/startswith?prefix=ab maps to
following code

class Controller_Word extends Controller_Mytemplate {
    public function action_startswith($fragment){
     /// Here $fragment should get "ab" value.
    }
}

Also could anyone tell me how can I get GET data in Kohana 3.2 controller?
For the above scenario I can solve it by,

class Controller_Word extends Controller_Mytemplate {
    public function action_startswith($fragment=null){
        if($fragment==null){
            /// set $fragment to $_GET['prefix'] but in Kohana way.
        }
    }
}



-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

Re: [kohana] Map query string to controller method parameter in Kohana 3.2

From:
Woody Gilk
Date:
2012-01-05 @ 00:37
On Wed, Jan 4, 2012 at 4:31 PM, shiplu <shiplu.net@gmail.com> wrote:
> The question is already asked in stackoverflow. Now giving it here, in this
> dead list.

Welcome to the Twilight Zone.

> Also could anyone tell me how can I get GET data in Kohana 3.2 controller?

$this->request->query()
--
Woody Gilk
http://about.me/shadowhand

Re: [kohana] Map query string to controller method parameter in Kohana 3.2

From:
shiplu
Date:
2012-01-05 @ 00:41
On Thu, Jan 5, 2012 at 6:37 AM, Woody Gilk <woody.gilk@gmail.com> wrote:

> $this->request->query()


Ah, Who knew it would be 'query' ? I was hoping a method named 'get'.
Thanks though. Any idea about the first part of the question?

-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

Re: [kohana] Map query string to controller method parameter in Kohana 3.2

From:
Woody Gilk
Date:
2012-01-05 @ 02:55
On Wed, Jan 4, 2012 at 6:41 PM, shiplu <shiplu.net@gmail.com> wrote:
> Ah, Who knew it would be 'query' ? I was hoping a method named 'get'.
> Thanks though. Any idea about the first part of the question?

Kohana stopped supporting function parameters for actions in v3.2.

--
Woody Gilk
http://about.me/shadowhand

Re: [kohana] Map query string to controller method parameter in Kohana 3.2

From:
shiplu
Date:
2012-01-05 @ 11:19
On Thu, Jan 5, 2012 at 8:55 AM, Woody Gilk <woody.gilk@gmail.com> wrote:

> On Wed, Jan 4, 2012 at 6:41 PM, shiplu <shiplu.net@gmail.com> wrote:
> > Ah, Who knew it would be 'query' ? I was hoping a method named 'get'.
> > Thanks though. Any idea about the first part of the question?
>
> Kohana stopped supporting function parameters for actions in v3.2.
>

I see. So how do I get "ab" in controller if my url is like
word/startswith/ab or even word/startswith/prefix/ab/


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

Re: [kohana] Map query string to controller method parameter in Kohana 3.2

From:
Woody Gilk
Date:
2012-01-08 @ 03:16
On Thu, Jan 5, 2012 at 5:19 AM, shiplu <shiplu.net@gmail.com> wrote:
>
> On Thu, Jan 5, 2012 at 8:55 AM, Woody Gilk <woody.gilk@gmail.com> wrote:
>>
>> Kohana stopped supporting function parameters for actions in v3.2.
>
> I see. So how do I get "ab" in controller if my url is like
> word/startswith/ab or even word/startswith/prefix/ab/
>

Use $this->request->param($name) instead.

--
Woody Gilk
http://about.me/shadowhand

Re: [kohana] Map query string to controller method parameter in Kohana 3.2

From:
Dave Carlson
Date:
2012-01-05 @ 00:42
i normally use Arr::get($_GET, "prefix");

-- 
Dave Carlson


On Thursday, 5 January 2012 at 00:41, shiplu wrote:

> 
> 
> On Thu, Jan 5, 2012 at 6:37 AM, Woody Gilk <woody.gilk@gmail.com 
(mailto:woody.gilk@gmail.com)> wrote:
> > $this->request->query()
> Ah, Who knew it would be 'query' ? I was hoping a method named 'get'. 
> Thanks though. Any idea about the first part of the question?
> 
> -- 
> Shiplu.Mokadd.im (http://Shiplu.Mokadd.im)
> ImgSign.com (http://ImgSign.com) | A dynamic signature machine
> Innovation distinguishes between follower and leader
>