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] 2   Go Down

Author Topic: How to use php in my template  (Read 11438 times)

0 Members and 1 Guest are viewing this topic.

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
How to use php in my template
« on: September 01, 2007, 06:09:22 pm »

Hi,
I've installed a gallery on my website and I'm doing a theme for it to fit into the overall design of the site.
I'de like to use php on the template, like adding my includes and more but the main template file is in html.
Is there a way I can change that in order to modify the template how I'd want ?

Thanx in advance
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #1 on: September 01, 2007, 06:13:43 pm »

No. Use the custom header/footer feature to include php files.
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #2 on: September 01, 2007, 06:49:25 pm »

Ok thanx. I guess I'll have to do that.
But I have some php code that I have to put before the html code begins or it won't work. And page header's content appears in the middle of the html code, just after the <body> tag. How can I put php code higher in the code, at the top of it ?
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #3 on: September 01, 2007, 08:37:31 pm »

You can't have output before the start of the html. It's not valid. If you want php code to run before any page output then use the custom header feature as suggested.
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #4 on: September 02, 2007, 11:56:34 pm »

well it doesn't seem to work. When I put an include in the custom header fucntions it doesn't work, an error occurs
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #5 on: September 03, 2007, 12:56:29 am »

Why don't you post what the error is? That's what a support board is for.
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #6 on: September 03, 2007, 09:38:40 am »

it says :
Parse error: syntax error, unexpected '<' in /home.10.9/legacynj/www/fr/gallery/themes/lnjo/theme.php on line 1164
It does that when I include a php file in the custum header.
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #7 on: September 03, 2007, 10:01:14 am »

Post your code.
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #8 on: September 03, 2007, 12:03:49 pm »

actually my template is a copy of the sample template. All I did is ad my include at the end of the header function like that :

Code: [Select]
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);
include($_SERVER["DOCUMENT_ROOT"].'/fr/includes/rn-main.php');
}
It works without the incliude
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #9 on: September 03, 2007, 05:29:14 pm »

Don't copy the entire sample theme. You should only copy the parts you want to change. Anyway, you must have done more than that to cause the error message you posted.Post line 1164 and a few lines above/below.
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #10 on: September 03, 2007, 08:05:13 pm »

I'm sorry, I got it wrong when you said custom header, I tought you were talking about the header function in the theme.php file. I corrected it. I deleted the files, and did it again from the beginning. This time I didn't edit the theme files (they are a copy from the sample template). All I did was to create a new file called header.inc.php that I put on the root of my gallery and I specified it's name on the configuration panel as the custom header. The only code I included in this file is :
Code: [Select]
<?php
include('../includes/rn-main.php');
?>

The error I get on any page of my gallery is :
Code: [Select]
Fatal error: Call to undefined function: append_sid() in /home.10.9/legacynj/www/fr/includes/rn-main.php on line 41
I don't get why it won't work. Do you have an idea of what's causing this ?
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #11 on: September 03, 2007, 08:09:17 pm »

Apparently the file you are including needs other files to work. Make sure the paths are correct. They should be as seen from the Coppermine directory.
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #12 on: September 03, 2007, 09:00:29 pm »

Yeh you're actualy right. It'sd because of the code that I need to be included before the html. I could put that code before the html if I put {CUSTOM_HEADER} at the very beginning of the file. But then I already use the custom header into the body to include that rn-main.php file, and I already use the footer for the includes that are after the main gallery part. Is there a way I can ad another custom part appart from the custom header and custom footer ?
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #13 on: September 03, 2007, 09:10:58 pm »

Moving {CUSTOM_HEADER} around makes no difference. The code you put there is already being run before any html is output. The result is captured and put in with the rest of the header. The header is then output complete.
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #14 on: September 04, 2007, 04:37:11 pm »

I think i've know where the problem is. Actually I have phpbb sessions loaded in my pages.
As you can see on my site here there's a login form on the right (it's in rn-main.php wich is an include displayed in every pages of my site). So finally phpbb sessions are included in rn-main.php
My gallery is bridged with phpbb, so it has phpbb sessions loaded too, and I guess it's not working because it loads the sessions 2 times in the same page and that's probably why it generates an error when I include rn-main.

Is there a way I could I remove the session call from the galery so it won't clash with rn-main's ?
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #15 on: September 04, 2007, 06:56:58 pm »

Is there a way I could I remove the session call from the galery so it won't clash with rn-main's ?

No, because there is no such thing.,
Logged

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #16 on: September 04, 2007, 07:18:36 pm »

how could this be ? Isn't coppermine supposed to be using phpbb sessions when it's briged with it ?
It must use the sessions in order to have users logued in the gallery.
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: How to use php in my template
« Reply #17 on: September 04, 2007, 11:33:31 pm »

Coppermine uses Cookie
Logged
‍I don't answer to PM with support question
Please post your issue to related board

saith

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 37
Re: How to use php in my template
« Reply #18 on: September 05, 2007, 02:05:32 pm »

well I don't know why but when I ad my include wich contain the session gestions, the gallery won't work, it doesn't even show an erro message, the page is blank. The include is fine since it works on every other pages of my website. The include contain :
Code: [Select]
<?php
define
('IN_PHPBB'true);
//COPIE SUR LA PAGE PARENTE $phpbb_root_path = '../forum/';
include($phpbb_root_path 'extension.inc');
//include($_SERVER["DOCUMENT_ROOT"].'/forum/extension.inc');
include($phpbb_root_path 'common.'.$phpEx);
 
$redirect_login '../../' $_SERVER['PHP_SELF'];
$redirect_logout '../../' $_SERVER['PHP_SELF'];
//$redirect_login = '../index.'.$phpEx;
//$redirect_logout = '../index.'.$phpEx;
//
// Start session management
//
$userdata session_pagestart($user_ipPAGE_SITE);
init_userprefs($userdata);
//
// End session management
//

$logout htmlspecialchars($HTTP_GET_VARS['logout']);

if ( 
$logout )
{
   
session_end($userdata['session_id'], $userdata['user_id']);
   
redirect(append_sid($redirect_logout));
}
?>


Do you have an idea why it won't work ?
Logged

Nibbler

  • Guest
Re: How to use php in my template
« Reply #19 on: September 05, 2007, 02:11:34 pm »

How is $phpbb_root_path set?
Logged
Pages: [1] 2   Go Up
 

Page created in 0.025 seconds with 19 queries.