Welcome Guest, Not a member yet? Register   Sign In
Undefined index: except in_array() expects parameter 2 to be array, null given
#1

[eluser]johnmerlino[/eluser]
Hey all,

I'm trying to use the before_filter code posted here:

http://ellislab.com/forums/viewthread/76228/

When I put this in one of my controllers:

var $before_filter = array('name' => 'vanity_activated', 'only' => array('get_blogger'));


And I have this in my routes:

$route['blogs/([a-z_-]+)'] = "blogs/get_blogger";

I expect the vanity_activated method to execute only when people use urls like this:
mysite/blogs/johnmerlino
mysite/blogs/sallyann
etc

But two problems happen:

1) I get an exception:
Severity: Notice

Message: Undefined index: except

Filename: hooks/Filter.php

Line Number: 41

Severity: Warning

Message: in_array() expects parameter 2 to be array, null given

Filename: hooks/Filter.php

Line Number: 41

2) It doesn't work as demonstrated. The method vanity_activated gets called before every method in the controller, not just the get_blogger one, which is what I want to happen.

For the first problem I see what happens:


if(in_array($called_function, $CI->before_filter["except"])){
call_user_func(array($CI,$CI->before_filter["name"]));
}

Because there is no 'except' in the array, since I am using 'only' instead, except is null here and rather than converting the statement to true or false for that if, it throws an exception saying in_array requires two arguments.

Any way to address these problems?
thanks for response


Messages In This Thread
Undefined index: except in_array() expects parameter 2 to be array, null given - by El Forum - 04-07-2011, 10:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB