[eluser]stormbytes[/eluser]
Sorry about that Phil -
I wrote that post at 4am. I guess I was pretty tired and perhaps even somewhat incoherent.
I'm writing a helper function that will output individual list-elements (<li><a>nav-link-item</a></li>) to a navigation menu. I'm using the URI class 'uri_string()' function to determine the 'current-page' when deciding if a given list-element should output as a link or static text. If the 'current-page' is say, 'about', the 'about' list-element will output as static text since no link is needed (the user is at that page).
The site's root URL can either be "example.com/default-controller", in which case uri_string() will return '/default-controller', or it can be "example.com" in which case uri_string() will return "". To trap this potential error, I'm using another class I wrote. The class "globals" is simply a config-loader. That is, a configuration file ('globals.php - config file') exists in application/config and contains a series of custom $config array elements. One of these elements is $default_controller (as specified in Routes.php). The "globals" (config-loader) class has been added to CI's Autoload, takes the globals-config-file as its argument and simply outputs each of the $config array elements as 'global variables', using $CI->load->vars().
In my nav-link function, I'm trying to access $default_controller so that I can equate it with base_url(). That is, if uri_string() returns EITHER "" OR $default_controller, the 'current-page' is obviously "root url" (or base_url()) and no anchor is needed on the "Home" list-element.
Now..
The problem I'm having is that I am unable to gain access to $default_controller from within my helper function. I don't understand why that is or how to remedy the situation. I even tried accessing my custom config file to pull the $default_controller value through $CI->config->item($default_controller) which didn't work either.
I hope you find this post more sensibly written, I certainly took the time and put in the effort.
Thanks for all the help. I really can't overstate how much this has contributed to integrating CI into my workflow and my growing love for it!