Imtehbegginer Posted July 16, 2009 Share Posted July 16, 2009 I have a system.php file with a class called wowcms. In wowcms there is a function called show_error($error); So on my index.php page I include it and do $wowcms = new wowcms; I also have a template function that includes the header.tpl, index.tpl, and footer.tpl. But when I do a $wowcms->show_error('blahblahblahblah'); nothing comes up. But if I do it on index.php it works.. What do I do so that i can use it globally? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted July 16, 2009 Share Posted July 16, 2009 Is there a problem with instantiating a new wowcms object? Did you consider making the method static? Can you pass around the wowcms object between routines? As a last resort, can the wowcms object be a singleton? (I'm not a fan of singletons, but it's still a little better than a global variable) There are plenty of ways to do it other than using global variables Quote Link to comment Share on other sites More sharing options...
Imtehbegginer Posted July 16, 2009 Author Share Posted July 16, 2009 class wowcms { var $config; function config() { @include('includes/config.php'); $this->config = $config; } function load_template($theme) { require('templates/'.$theme.'/header.tpl'); require('templates/'.$theme.'/index.tpl'); require('templates/'.$theme.'/footer.tpl'); } function show_error($text) { echo($text); } function fatal_error($text) { die($text); } } There is my system.php. Now on my index I use $wowcms = new wowcms; then i require my template blah blah. Now on the template I do $wowcms->show_error('whatever'); nothing shows up. Can you show me an example of what you mean? Quote Link to comment Share on other sites More sharing options...
Imtehbegginer Posted July 16, 2009 Author Share Posted July 16, 2009 Anyone know what to do? Quote Link to comment Share on other sites More sharing options...
Imtehbegginer Posted July 16, 2009 Author Share Posted July 16, 2009 Nevermind, I figured it out. Thanks genericnumber1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.