Path to theme Path to theme
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Path to theme

Started by nanothree, January 08, 2005, 10:37:46 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nanothree

I sthere a variable that holds the path to the theme? i want to use the delete image but i want to make sure it will wokr with any theme that has a delete image in themes/THEME_NAME/images/

Abbas Ali

$CONFIG['theme']
holds the theme name.

You can use "themes/".$CONFIG['theme']."/images/"; to go to current theme's images directory
Chief Geek at Ranium Systems

nanothree

hmmmm there is a rather odd problem, if i use:

echo$CONFIG['theme'];

it outputs the theme, however if i use it inside my function:

function links(){
$sql = 'SELECT * FROM links ORDER BY name';
$sql = mysql_query($sql);
echo '<table width="100%"  border="0" cellspacing="0" cellpadding="0">';
while($r = mysql_fetch_array($sql)){
  echo
  '<tr>
<td width="70%"><h1><a href="'.$r['url'].'">'.$r['name'].'</a></h1></td>
<td width="30%"><a href="'.$_SERVER['PHP_SELF'].'?action=report&id='.$r['id'].'" title="'.$lang_links_php['report'].'"><div align="right"><img src="themes/'.$CONFIG['theme'].'/images/delete.gif" border="0" alt="Report Bad Link"></a></div></td>
  </tr>
  <tr>
<td colspan="2">'.$r['description'].'</td>
  </tr>';
};
echo '</table>';
};


it doesnt work can you see why?

Joachim Müller

try $USER['theme'] - the code // Process theme selection if present in URI or in user profile
if (!empty($HTTP_GET_VARS['theme'])) {
    $USER['theme'] = $HTTP_GET_VARS['theme'];
}
// Load theme file
if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' . $USER['theme'])) {
    $CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`', '____________');
} else {
    unset($USER['theme']);
}

if (!file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'classic';
require "themes/{$CONFIG['theme']}/theme.php";
$THEME_DIR = "themes/{$CONFIG['theme']}/";
// Process language selection if present in URI or in user profile or try
// autodetection if default charset is utf-8
if (!empty($HTTP_GET_VARS['lang'])) {
    $USER['lang'] = $HTTP_GET_VARS['lang'];
}
in include/init.inc.php fills those vars.

Joachim

Nibbler

To access an external variable within a function you need to globalise it - this is basic php.

donnoman

It's exactly what nibbler said.

your function doesn't have access to variables outside of it unless they are globalised variables.


function links(){
 global $CONFIG;



http://www.zend.com/manual/language.variables.scope.php

nanothree

i undersatand now, i feel really silly lol