Home
Forums
Members
Search
Help
New topics
Todays topics
Website
Welcome Guest, Not a member yet?
Register
Sign In
Login
Username:
Password:
Remember me
Lost Password?
CodeIgniter Forums
Archived Discussions
Archived Development & Programming
Way to get a config value from a helper
Share on Google
Share on Facebook
Share on Twitter
View a Printable Version
Subscribe to this thread
Add Poll to this thread
Send thread to a friend
Linear Mode
Threaded Mode
Way to get a config value from a helper
El Forum
Guest
#1
04-21-2010, 11:39 AM
[eluser]earlyriser[/eluser]
Inside a helper, $this->config->item('item name'); doesn't work.
Is there a way to fetch a config value from there? Without passing the value as a function parameter.
Thanks
El Forum
Guest
#2
04-21-2010, 12:35 PM
[eluser]danmontgomery[/eluser]
$this doesn't work at all because helpers aren't class methods.
Code:
$CI =& get_instance();
$value = $CI->config->item('item_name');
El Forum
Guest
#3
04-22-2010, 06:45 AM
[eluser]earlyriser[/eluser]
Thanks noctrum. I wasn't sure about that.
El Forum
Guest
#4
04-22-2010, 01:19 PM
[eluser]janogarcia[/eluser]
You could even do this
Code:
$value = config_item('item_name');
If you don't need access to the CI super object, the global function
config_item()
(defined in Common.php) comes in very handy.
El Forum
Guest
#5
04-22-2010, 02:46 PM
[eluser]cahva[/eluser]
Yeah I use the config_item() all the time. Its shorter, sweeter and works everywhere
--------------------
Private Messages
User Control Panel
Who's Online
Search
Forum Home
General
-- News & Discussion
-- Events
-- Lounge
-- Regional User Groups
Using CodeIgniter
-- Installation & Setup
-- Model-View-Controller
-- Libraries & Helpers
-- Best Practices
-- Choosing CodeIgniter
-- General Help
CodeIgniter 4
-- CodeIgniter 4 Roadmap
-- CodeIgniter 4 Development
-- CodeIgniter 4 Feature Requests
-- CodeIgniter 4 Support
-- CodeIgniter 4 Discussion
-- CodeIgniter 4 Addins
Development
-- CodeIgniter 3.x
-- CodeIgniter 2.x
-- Issues
-- NetBeans Plugin
External Resources
-- Spotlight
-- Learn More
-- Jobs
-- Addins
Archived Discussions
-- Archived Libraries & Helpers
-- Archived Development & Programming
Theme © iAndrew 2016 -
Forum software by © MyBB