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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.