Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Writing the code for a {token} in theme.php  (Read 5746 times)

0 Members and 1 Guest are viewing this topic.

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Writing the code for a {token} in theme.php
« on: December 05, 2005, 03:06:40 pm »

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.
« Last Edit: December 14, 2005, 08:14:08 am by GauGau »
Logged

Nibbler

  • Guest
Re: Writing the code for a {token} in theme.php
« Reply #1 on: December 05, 2005, 03:22:19 pm »

Look at the pageheader() function.
Logged

myself

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: Writing the code for a {token} in theme.php
« Reply #2 on: December 06, 2005, 05:17:34 am »

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
Code: [Select]
$template_user_information &
Code: [Select]
'{USER_INFO}' => $template_user_information,
Code: [Select]
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}
Code: [Select]
// 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.
Code: [Select]
<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.
« Last Edit: December 06, 2005, 06:02:18 am by myself »
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Writing the code for a {token} in theme.php
« Reply #3 on: December 07, 2005, 06:13:20 am »

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.
Logged

majay

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 33
Re: Writing the code for a {token} in theme.php
« Reply #4 on: December 13, 2005, 06:16:25 pm »

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:
Code: [Select]
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.
« Last Edit: December 13, 2005, 08:59:24 pm by Morgane »
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Writing the code for a {token} in theme.php
« Reply #5 on: December 15, 2005, 04:31:43 am »

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.

Logged
Pages: [1]   Go Up
 

Page created in 0.015 seconds with 19 queries.