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: defining custom template vars  (Read 4603 times)

0 Members and 1 Guest are viewing this topic.

thapame

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
defining custom template vars
« on: April 07, 2007, 04:13:44 pm »

how to define custom template vars like {SUB_MENU}, {ADMIN_MENU} etc and use it on template.html file
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: defining custom template vars
« Reply #1 on: April 07, 2007, 08:40:18 pm »

You should set them under {gallery-root}\themes\your theme\theme.php
check orginal theme's theme.php that comes with installation package
Logged
‍I don't answer to PM with support question
Please post your issue to related board

thapame

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
Re: defining custom template vars
« Reply #2 on: April 09, 2007, 09:13:59 am »

well I could not find anything except functions on theme.php and also the function name and vars name doesnot match. So I get confused on how to define vars.

Will you explain me in details or give me an example.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: defining custom template vars
« Reply #3 on: April 09, 2007, 09:45:12 am »

If a function or var is not being defined in your custom theme, copy the function (or var definition) from themes/sample/theme.php into themes/yourtheme/theme.php. Then edit themes/yourtheme/theme.php as you see fit. The concept is: there are default functions and variables defined within coppermine that are being taken into account unless you specify something special in your custom theme. This way, your custom theme will stay lightweight and easy tu upgrade, as only the stuff that you need to behave differently to the default will actually get changed.
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: defining custom template vars
« Reply #4 on: April 09, 2007, 09:56:28 am »

here is more info :
add these two line at very first of {gallery-root}\themes\your custom theme\theme.php
Code: [Select]
define('THEME_HAS_NO_SYS_MENU_BUTTONS', 1);
define('THEME_HAS_NO_SUB_MENU_BUTTONS', 1);

- you should set sys_menu template by setting $template_sys_menu variable (check hardwire/theme.php for example)
- you should set sub_menu template by setting $template_sub_menu variable (check hardwire/theme.php for example)
Logged
‍I don't answer to PM with support question
Please post your issue to related board

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: defining custom template vars
« Reply #5 on: April 09, 2007, 10:00:33 am »

Technical sidenote: the settings above are not variables, but constants.
Logged

thapame

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
Re: defining custom template vars
« Reply #6 on: April 09, 2007, 12:10:05 pm »

here is more info :
add these two line at very first of {gallery-root}\themes\your custom theme\theme.php
Code: [Select]
define('THEME_HAS_NO_SYS_MENU_BUTTONS', 1);
define('THEME_HAS_NO_SUB_MENU_BUTTONS', 1);

- you should set sys_menu template by setting $template_sys_menu variable (check hardwire/theme.php for example)
- you should set sub_menu template by setting $template_sub_menu variable (check hardwire/theme.php for example)


well as per your post I tried following

in theme.php
===============
define('THEME_HAS_NO_TOP_DATA_BUTTONS', 1);

// HTML template for top_data
$template_top_data = <<<EOT
---contents---
EOT;


and in template.html
====================
{TOP_DATA}



but it is not working. let me if i am wrong
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: defining custom template vars
« Reply #7 on: April 10, 2007, 07:47:29 am »

You can not just make up variables and constants and hope that they will do something. You'll have to define them in the corresponding functions. Is your placeholder token in template.html suppossed to show before or after the {GALLERY}-token?
Logged

thapame

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
Re: defining custom template vars
« Reply #8 on: April 10, 2007, 08:44:01 am »

You can not just make up variables and constants and hope that they will do something. You'll have to define them in the corresponding functions. Is your placeholder token in template.html suppossed to show before or after the {GALLERY}-token?

it's before {GALLERY}.
will you let me know what I have to do to make and use for example: {TOP_DATA} var or constant
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: defining custom template vars
« Reply #9 on: April 11, 2007, 08:32:15 am »

edit themes/yourtheme/theme.php, find
Code: [Select]
function pageheader($section, $meta = '')and modify as suggested below. If you don't have that function in your custom theme, copy
Code: [Select]
// Function for writing a pageheader
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

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

        $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
        header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $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,
        );

    echo template_eval($template_header, $template_vars);
}
from themes/sample/theme.php into a new line before
Code: [Select]
?>in themes/yourtheme/theme.php

Then edit the code you just pasted in: find
Code: [Select]
        '{CUSTOM_HEADER}' => $custom_header,and add after it (into a new line)
Code: [Select]
        '{TOP_DATA}' => $template_top_data,
Logged

thapame

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
Re: defining custom template vars
« Reply #10 on: April 11, 2007, 09:18:01 am »

I added:
Code: [Select]
// HTML template for top_data
$template_top_data="some text here";

// Function for writing a pageheader
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

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

        $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
        header("Content-Type: text/html; charset=$charset");
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $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,
'{TOP_DATA}' => $template_top_data,
        );

    echo template_eval($template_header, $template_vars);
}

in theme.php before
Code: [Select]
?>
and

Code: [Select]
{TOP_DATA}
before

Code: [Select]
{GALLERY}
in template.html but the contents of $template_top_data is not showing.

am I wrong anywhere??
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: defining custom template vars
« Reply #11 on: April 11, 2007, 12:08:14 pm »

Zip your theme folder and attach it to this post by using additional option, I'll check it
Logged
‍I don't answer to PM with support question
Please post your issue to related board

thapame

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 72
Re: defining custom template vars
« Reply #12 on: April 19, 2007, 03:21:56 pm »

here is the zipped file.
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 15 queries.