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/
$CONFIG['theme']
holds the theme name.
You can use "themes/".$CONFIG['theme']."/images/";
to go to current theme's images directory
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?
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
To access an external variable within a function you need to globalise it - this is basic php.
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
i undersatand now, i feel really silly lol