forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: AzorMachine on September 07, 2011, 04:22:42 pm

Title: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 04:22:42 pm
I've searched in the docs, and as I didn't found an entry about that, I'm here asking.
Is there a simple way to create custom tokens, to populate my template.html?
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 07, 2011, 05:10:46 pm
All tokens you place before the {GALLERY} token need to be replaced within the function pageheader, all that are placed after that token within the pagefooter function.
Title: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 05:49:42 pm
That means, "Use {CUSTOM_FOOTER} and {CUSTOM_HEADER}" ?
I was going to use both, But I need one more field to display php code.
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 07, 2011, 06:52:47 pm
No. Just add the tokens where you need it and fill it with content in the mentioned functions in theme.php. Of course you can use the custom header/footer feature to include your PHP code.
Title: Re: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 07:12:53 pm
No. Just add the tokens where you need it and fill it with content in the mentioned functions in theme.php. Of course you can use the custom header/footer feature to include your PHP code.

And how would stay the code in theme.php, if I want a token to show the statistics of my gallery? (19 files in 6 albums and 2 categories with 0 comments viewed 466,770 times) (But whithout the comments number.)
Sorry for the inconvenience, but that is an important code to release my gallery, today.
Thanks.
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 07, 2011, 07:26:34 pm
Please have a look at the files template.html and theme.php of the sample theme to understand how it works. All tokens above the {GALLERY} token are replaced within the function pageheader, all tokens below the {GALLERY} token are replaced within the function pagefooter. If you understand that example it should be quite easy to add new tokens in template.html.


Please explain exactly what you try to accomplish if you need specific support.
Title: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 07:34:27 pm
Quote
Please explain exactly what you try to accomplish if you need specific support.

I wanna that one of the tabs in my gallery, show the statistics of the gallery, without the comments numbers, like :

Quote
19 files in 6 albums and 2 categories viewed 466,770 times
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 07, 2011, 07:45:56 pm
Sorry, but, which tabs? Please post a link to your gallery and a link to that 'tab'.
Title: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 07:54:38 pm
The table that says Estatísticas in the footer area.

www.reinorpg.com/resources
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 07, 2011, 08:04:18 pm
Replace that word with a token of your choice (e.g. {STATISTICS}) and extend the $template_vars array in the pagefooter function. If that function doesn't exist in your theme.php file, just copy it from the sample theme.
Title: Re: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 08:15:07 pm
Replace that word with a token of your choice (e.g. {STATISTICS}) and extend the $template_vars array in the pagefooter function. If that function doesn't exist in your theme.php file, just copy it from the sample theme.

Done.
Now the function has this line :

Code: [Select]
'{STATISTICS}' => blank,

But what code should be in the 'blank', to show the statistics, without the comments?
Title: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 08:18:01 pm
Ok,
Code: [Select]
$statisticsright?

But how to remove the comments from it?
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 07, 2011, 08:19:35 pm
You have to grab the information from the database yourself and then build the string.
Title: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 07, 2011, 08:44:29 pm
Added this to my theme.php :

Code: [Select]
/******************************************************************************
** Section <<<pagefooter>>> - START
******************************************************************************/
// Function for writing a pagefooter
function pagefooter()
{
    //global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $CONFIG, $time_start, $query_stats, $queries;
    global $template_footer;

    $custom_footer = cpg_get_custom_include($CONFIG['custom_footer_path']);

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
        cpg_debug_output();
    }

    $template_vars = array(
        '{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,
        '{STATISTICS2}' => $statistics,
        '{JAVASCRIPT}' => theme_javascript_head(),
        '{CUSTOM_FOOTER}' => $custom_footer,
        '{VANITY}' => (defined('THEME_IS_XHTML10_TRANSITIONAL')) ? theme_vanity() : '',
        '{CREDITS}' => theme_credits(),
    );

    echo template_eval($template_footer, $template_vars);
}
/******************************************************************************
** Section <<<pagefooter>>> - END
******************************************************************************/

And added the {STATISTICS2} token to my template.html, But nothing is shown.
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 07, 2011, 09:28:28 pm
As I said, the variable $statistics doesn't contain anything at this place. That's why you need to fill it yourself with information from the database. I'm currently too short of time to create a working solution for you.
Title: Re: Re: How to create a custom Token for Coppermine
Post by: AzorMachine on September 08, 2011, 03:19:37 pm
As I said, the variable $statistics doesn't contain anything at this place. That's why you need to fill it yourself with information from the database. I'm currently too short of time to create a working solution for you.

When you have time, please take a time at this. It's kinda importante for my gallery, and It's something I can't make by myself.

Best Regards.
Title: Re: How to create a custom Token for Coppermine
Post by: Αndré on September 09, 2011, 12:13:02 pm
Use this function:
Code: [Select]
/******************************************************************************
** Section <<<pagefooter>>> - START
******************************************************************************/
// Function for writing a pagefooter
function pagefooter()
{
    //global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $CONFIG, $time_start, $query_stats, $queries;
    global $template_footer;

    $custom_footer = cpg_get_custom_include($CONFIG['custom_footer_path']);

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
        cpg_debug_output();
    }

    $files = mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']}"), 0);
    $albums = mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_ALBUMS']}"), 0);
    $categories = mysql_result(cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_CATEGORIES']}"), 0);
    $views = mysql_result(cpg_db_query("SELECT SUM(hits) FROM {$CONFIG['TABLE_PICTURES']}"), 0);
    $statistics = "$files files in $albums albums and $categories categories viewed $views times";
   
    $template_vars = array(
        '{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,
        '{STATISTICS2}' => $statistics,
        '{JAVASCRIPT}' => theme_javascript_head(),
        '{CUSTOM_FOOTER}' => $custom_footer,
        '{VANITY}' => (defined('THEME_IS_XHTML10_TRANSITIONAL')) ? theme_vanity() : '',
        '{CREDITS}' => theme_credits(),
    );

    echo template_eval($template_footer, $template_vars);
}
/******************************************************************************
** Section <<<pagefooter>>> - END
******************************************************************************/