Welcome Guest, Not a member yet? Register   Sign In
$_SERVER['SCRIPT_FILENAME'] always returns index.php path. what are alternatives?
#1

[eluser]faluci[/eluser]
I have $_SERVER['SCRIPT_FILENAME'] in custom helper function.

This always seem to return the main index.php.

I want to retrieve actual directory of the controller when the helper script is called.

How?
#2

[eluser]InsiteFX[/eluser]
Code:
// ------------------------------------------------------------------------

/**
* Helper Name
*
* @access public
* @return void
*/
if ( ! function_exists('helper_name'))
{
    function helper_name()
    {
        $CI = get_instance();

        $controller   = $this->CI->router->fetch_class();
        $this->method = $this->CI->router->fetch_method();
      
        // now you can search the directories for the controller name
    }
}
#3

[eluser]faluci[/eluser]
thanks for fast reply. I'm sure the above will work. Big Grin
#4

[eluser]InsiteFX[/eluser]
You should already know where your controller directories are under ./application/controllers

And what I showed above will allow you to get the controller name and method name.




Theme © iAndrew 2016 - Forum software by © MyBB