defining custom template vars defining custom template vars
 

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

Main Menu

defining custom template vars

Started by thapame, April 07, 2007, 04:13:44 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

thapame

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

Sami

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

thapame

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.

Joachim Müller

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.

Sami

here is more info :
add these two line at very first of {gallery-root}\themes\your custom theme\theme.php

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)
‍I don't answer to PM with support question
Please post your issue to related board

Joachim Müller

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

thapame

Quote from: Sami 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

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

Joachim Müller

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?

thapame

Quote from: GauGau 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?

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

Joachim Müller

edit themes/yourtheme/theme.php, find function pageheader($section, $meta = '')and modify as suggested below. If you don't have that function in your custom theme, copy// 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?>in themes/yourtheme/theme.php

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

thapame

I added:
// 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
?>

and

{TOP_DATA}

before

{GALLERY}

in template.html but the contents of $template_top_data is not showing.

am I wrong anywhere??

Sami

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

thapame

here is the zipped file.