Jump to content

Template problem


stuffradio

Recommended Posts

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

<?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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.