Editing theme.php Editing theme.php
 

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]

Main Menu

Editing theme.php

Started by quake101, August 22, 2004, 07:01:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

quake101

I'm adding some custom php to the "header", ex: '{test}' => test(),. Every time I make the funtion under the $template_vars array. I get errors. Am i putting the funtion in the wrong place? I noticed in the FAQ it tells you how to customize the array but don't tell you where to put a var or funtion at. Any help on this would be great. Thanks. :)

quake101

I still need help with this. :(

Joachim Müller

allow days for answers, not hours - this is not a hotline. >:(

GauGau

quake101

I only posted "I still need help with this" cuz you moved the post. I started this post last night also. I didn't wait hours. It's been almost a day and I haven't gotten anything from the post yet. :( I also don't understand this, you took the time to tell me it's not a hotline but didn't take the time to help me. From your profile it looks like your the admin and project leader. I would think you could help me in a matter of mins.

Joachim Müller

obviously you're wrong: although I'm the project leader, I'm not the only supporter. There's no law that a supporter who moves a thread posted on the wrong board will have to take care of the issue. I repeat: this is not a hotline, alow days for answers, not hours. I didn't post an answer, because your question has been poorly written. The code snippet you posted doesn't mean anything - you will have to post the full code you have come up with so far, plus a description what you actually want to do. If you haven't come up with more code than the snippet you posted so far, then maybe you shouldn't change anything at this level of coding, since more coding skills are required to actually create a custom function within theme.php.
Neglecting board rules (posting an the wrong board, bumping too early) usually means a supproter is reluctant to help in the first place; that's why you get a slower response. I recommend you review your attitude; this is a support board of an open source app, where development and support is done by volunteers - you have no right on support, as you haven't piad a cent for the software.

GauGau

quake101

I never though this was a hotline nor said it was. I'm just smiply looking for some help. I just thought it was odd that you would take the time to yell at me and not just say "The code you included doesn't help, please give us a little more info or code then that". I'm sorry if i ticked you off I'm not here to make anyone mad. I'm just here for some help. Here is some more of the edited code from my theme.php. I hope this helps a bit more.


    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{test}' => test(),
        );
    funtion test(){
    echo "wooho it worked";
    }
    echo template_eval($template_header, $template_vars);


Nibbler

You spelled function wrong for a start, and the function must be declared before you attempt to call it. This is just basic php.

quake101

I have put the function before the arrary and i still got errors.

Nibbler


quake101

#9
This is the code with the function before the array.

   function test(){
   echo "yay";
   }
   $template_vars = array('{LANG_DIR}' => $lang_text_dir,
       '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
       '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
       '{META}' => $meta,
       '{GAL_NAME}' => $CONFIG['gallery_name'],
       '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
       '{MAIN_MENU}' => theme_main_menu(),
       '{ADMIN_MENU}' => theme_admin_mode_menu(),
       '{test}' => test(),
       );
   echo template_eval($template_header, $template_vars);

Here is the error I get.
Fatal error: Call to undefined function: () in /home/test/public_html/gallery/themes/default/theme.php on line 823

skybax

#10
You seem to break away from the style of coding for the header information. Also did you call {test} from within your template.html?

I added the ability to add a javascript onload command to the body tag. Here's the code for the answer to your question....


function pageheader($section, $meta = '', $javascript_onload_var = '')
{
   global $CONFIG, $THEME_DIR;
   global $template_header, $lang_charset, $lang_text_dir;
   header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
if ($javascript_onload_var != ""){
$javascript_onload_var = ' onLoad="' . $javascript_onload_var . '"';
}else{
$javascript_onload_var = "";
}
   user_save_profile();
   $template_vars = array('{LANG_DIR}' => $lang_text_dir,
       '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
'{JAVASCRIPT_ONLOAD}' => $javascript_onload_var,
       '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
       '{META}' => $meta,
       '{GAL_NAME}' => $CONFIG['gallery_name'],
       '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
       '{MAIN_MENU1}' => theme_main_menu1(),
       '{MAIN_MENU2}' => $include_main_menu2,
       '{ADMIN_MENU}' => theme_admin_mode_menu()
       );
   echo template_eval($template_header, $template_vars);
}


Then within template.html I added {JAVASCRIPT_ONLOAD} where I wanted the onload function to appear.

-T
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.skybax.com%2FhotImage%2Fpost_footer.gif&hash=338b65c57a59f0b06311094e697c87794e43d945)
Don't contact me for support over PM or email unless I requested you to do so. Instead: post on the proper board.

quake101

I do have {test} in the template.html

skybax

why not just use a if statement? because it seems that what you are doing would qualify for a simple if/else statement. also captialize the text between the { } (I didn't test this - but that could be what's giving you issues as well?).
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.skybax.com%2FhotImage%2Fpost_footer.gif&hash=338b65c57a59f0b06311094e697c87794e43d945)
Don't contact me for support over PM or email unless I requested you to do so. Instead: post on the proper board.

quake101

Good call skybax i'll give that a shot. :)

quake101

If i just just a var everything works fine, but I need to use a function. Bah I might just have to rewrite my script. :(

skybax

Why don't you post the code you are actually trying to use that way we can debug it for you, just putting up "test" won't help either one of us.

-T
(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.skybax.com%2FhotImage%2Fpost_footer.gif&hash=338b65c57a59f0b06311094e697c87794e43d945)
Don't contact me for support over PM or email unless I requested you to do so. Instead: post on the proper board.