forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Themes/Skins/Templates => Topic started by: quake101 on August 22, 2004, 07:01:22 am

Title: Editing theme.php
Post by: quake101 on August 22, 2004, 07:01:22 am
I'm adding some custom php to the "header", ex:
Code: [Select]
'{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. :)
Title: Re: Editing theme.php
Post by: quake101 on August 22, 2004, 09:26:50 pm
I still need help with this. :(
Title: Re: Editing theme.php
Post by: Joachim Müller on August 23, 2004, 12:27:24 am
allow days for answers, not hours - this is not a hotline. >:(

GauGau
Title: Re: Editing theme.php
Post by: quake101 on August 23, 2004, 01:34:28 am
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.
Title: Re: Editing theme.php
Post by: Joachim Müller on August 23, 2004, 07:07:03 am
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
Title: Re: Editing theme.php
Post by: quake101 on August 23, 2004, 04:41:43 pm
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.

Code: [Select]
    $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);
Title: Re: Editing theme.php
Post by: Nibbler on August 23, 2004, 07:22:26 pm
You spelled function wrong for a start, and the function must be declared before you attempt to call it. This is just basic php.
Title: Re: Editing theme.php
Post by: quake101 on August 23, 2004, 07:56:01 pm
I have put the function before the arrary and i still got errors.
Title: Re: Editing theme.php
Post by: Nibbler on August 23, 2004, 08:06:49 pm
Care to post the errors ?
Title: Re: Editing theme.php
Post by: quake101 on August 23, 2004, 08:17:26 pm
This is the code with the function before the array.
Code: [Select]
   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
Title: Re: Editing theme.php
Post by: skybax on August 23, 2004, 09:00:30 pm
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....

Code: [Select]
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
Title: Re: Editing theme.php
Post by: quake101 on August 23, 2004, 09:22:09 pm
I do have {test} in the template.html
Title: Re: Editing theme.php
Post by: skybax on August 24, 2004, 02:33:14 pm
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?).
Title: Re: Editing theme.php
Post by: quake101 on August 24, 2004, 06:33:23 pm
Good call skybax i'll give that a shot. :)
Title: Re: Editing theme.php
Post by: quake101 on August 24, 2004, 10:24:33 pm
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. :(
Title: Re: Editing theme.php
Post by: skybax on August 24, 2004, 10:33:35 pm
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