Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Path to theme  (Read 3270 times)

0 Members and 1 Guest are viewing this topic.

nanothree

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 70
    • RockThoseLocks
Path to theme
« on: January 08, 2005, 10:37:46 am »

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/
« Last Edit: January 09, 2005, 10:39:03 pm by GauGau »
Logged

Abbas Ali

  • Administrator
  • Coppermine addict
  • *****
  • Country: in
  • Offline Offline
  • Gender: Male
  • Posts: 2165
  • Spread the PHP Web
    • Ranium Systems
Re: Path to theme
« Reply #1 on: January 08, 2005, 01:29:15 pm »

Code: [Select]
$CONFIG['theme'] holds the theme name.

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

nanothree

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 70
    • RockThoseLocks
Re: Path to theme
« Reply #2 on: January 08, 2005, 03:00:01 pm »

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

Code: [Select]
echo$CONFIG['theme'];
it outputs the theme, however if i use it inside my function:
Code: [Select]
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?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Path to theme
« Reply #3 on: January 08, 2005, 04:05:44 pm »

try $USER['theme'] - the code
Code: [Select]
// 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
Logged

Nibbler

  • Guest
Re: Path to theme
« Reply #4 on: January 09, 2005, 05:32:32 pm »

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

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Path to theme
« Reply #5 on: January 09, 2005, 06:04:03 pm »

It's exactly what nibbler said.

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

Code: [Select]
function links(){
  global $CONFIG;


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

nanothree

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 70
    • RockThoseLocks
Re: Path to theme
« Reply #6 on: January 09, 2005, 09:23:17 pm »

i undersatand now, i feel really silly lol
Logged
Pages: [1]   Go Up
 

Page created in 0.027 seconds with 16 queries.