stuffradio Posted December 6, 2007 Share Posted December 6, 2007 I'm trying to find a way to define the default theme... and than make it access that theme. Config.php function siteConfig($siteValue) { $configValue = Array(); $configValue['default_theme'] = "themes/default/"; $configValue['root_base'] = "../"; // $configValue['default_lang'] = "lang/en/defines.php"; } templatevars.php <?php Class ParseFile { function displayPage($theme) { $content = file_get_contents($theme); $content = str_replace('%TITLE%', 'This is title!', $content); $content = str_replace('%LEFTNAV%', 'Blah<br />Blah<br />', $content); $content = str_replace('%CONTENT%', 'Welcome to my lair!', $content); return $content; } } ?> test.php require_once('includes/templatevars.php'); require_once('includes/config.php'); $parse = new ParseFile(); $config = new Config(); $default_theme = $config->siteConfig('default_theme'); $parse->displayPage($default_theme); Link to comment https://forums.phpfreaks.com/topic/80394-template-problem/ Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 And your question is? can we see your Config class? Link to comment https://forums.phpfreaks.com/topic/80394-template-problem/#findComment-407626 Share on other sites More sharing options...
stuffradio Posted December 6, 2007 Author Share Posted December 6, 2007 <?php Class Config { function connect() { mysql_connect(PREFIX_DB_HOST, DB_USERNAME, DB_PASSWORD); // Connects to a database that you specified mysql_select_db(DB_DATABASE); // Selects the Database you chose } function siteConfig($siteValue) { $configValue = Array(); $configValue['default_theme'] = "themes/default/"; $configValue['root_base'] = "../"; // $configValue['default_lang'] = "lang/en/defines.php"; } } ?> Nothing shows up on the page in test.php Link to comment https://forums.phpfreaks.com/topic/80394-template-problem/#findComment-407628 Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 What do you expect to show up? Your siteConfig() method does not return any values. You could use.... function siteConfig($siteValue) { $configValue = Array(); $configValue['default_theme'] = "themes/default/"; $configValue['root_base'] = "../"; // $configValue['default_lang'] = "lang/en/defines.php"; return $configValue[$siteValue]; } and it will work, but this whole system looks pretty dodgy to me. Link to comment https://forums.phpfreaks.com/topic/80394-template-problem/#findComment-407630 Share on other sites More sharing options...
stuffradio Posted December 6, 2007 Author Share Posted December 6, 2007 Well do you have any suggestions than? How can I improve it. Link to comment https://forums.phpfreaks.com/topic/80394-template-problem/#findComment-407640 Share on other sites More sharing options...
stuffradio Posted December 6, 2007 Author Share Posted December 6, 2007 I tried using return instead of echo... and it didn't return anything. When I use echo and I use a the variable $default_theme.. it shows: ÉÖ= .ÈÖ=@..ÊÖ=4+.pureftpd-upload.4756322d.15.1134e.38ae17e1ÊÖ=´ index.tpl<ë any ideas? Link to comment https://forums.phpfreaks.com/topic/80394-template-problem/#findComment-407661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.