Writing the code for a {token} in theme.php Writing the code for a {token} in 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

Writing the code for a {token} in theme.php

Started by myself, December 05, 2005, 03:06:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

myself

I would like to add some features but need help writting the code for a {token} that can then be used in the template.htm. I have looked at the sample theme but am not clear how to do this.

Nibbler


myself

#2
At first I thought your answer was a bit short, because I have looked at the pageheader/ pagefooter sections LOTS before. But you forced me to go back and re-examine them. After much study I have succeeded. I am posting my findings for others. This may be already posted elsewhere but I could not find it, so here it goes.

Step 1:
I added the following sections to the pageheader
$template_user_information & '{USER_INFO}' => $template_user_information,
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir, $template_user_information;

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
'{USER_INFO}' => $template_user_information,
        );

    echo template_eval($template_header, $template_vars);
}


Step 2.
I wrote the HTML template for the {Token}
// HTML template for the user information
$template_user_information = <<<EOT
<!-- BEGIN user information -->
        <b>Place user information here.</b>
<!-- END user information -->
EOT;


Step 3.
I added the {Token} as part of the template.html file.
<table class="maintable" width="150">
<tr>
<td class="tableh1">
User Information
</td>
<tr>
<td class="menutable">
{USER_INFO}
</td>
</tr>
</table>


I hope that helps. What you put in there is up to you.

donnoman

This is documented in the 1.3 documentation as the custom_header and custom_footer.

But since we now provide canned support for custom_headers and custom_footer's there was no need to carry that documentation forward.

If someone is looking at this again, you can check the 1.3 docs as an additional source.

majay

#4
I've been trying to do the same kind of thing, but as I've upgraded my theme.php file to cpg 1.4.2, the whole "// Template used for tabbed display" is gone. I've tried to add it back into the theme file but it results in displaying the content of my custom token right at the top of my page in addition to where I  placed the token in my template.html file. But I don't know enough to get around that problem.

My token is called {CUSTOM_HEADER} and it's a PHP counter script for my gallery which usually is displayed with my menu.
In the pageheader function in 1.3.4 I had added this:
if(empty($custom_header)){
      include('/home/gallery/public_html/script/counter.php');
      $custom_header = ob_get_contents();
      ob_clean();


So shoud I ignore 1.4.2 and just use my old theme file? Or is there a way to fix this?
Thanks.

Edit: Problem fixed, there were conflicting tags in my template that I had not seen, I'm sorry.

donnoman

Remember that although all the functions and templates don't exist in all of the core templates, it doesn't mean you can't override them.

1.4 includes MORE themeable functions and templates than 1.3, you just have to look at the sample theme to find them. If you find them worthy of overriding then move them to your custom theme and override to your hearts content.