coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: gflogic on February 07, 2006, 12:26:03 PM

Title: Adding Php to templates
Post by: gflogic on February 07, 2006, 12:26:03 PM
Hi everyone. I am making my own theme but I would like to add some php code to add some features and interaction with the rest of my website.

Where should I start to modify files ? Is it into include/themes.inc.php ?

Thanks.
Title: Re: Adding Php to templates
Post by: Tranz on February 07, 2006, 03:34:47 PM
http://forum.coppermine-gallery.net/index.php?topic=24056.0
Title: Re: Adding Php to templates
Post by: gflogic on February 07, 2006, 10:05:29 PM
Ok I spent 2 hours reading the whole documentation and trying stuff... There is no way to add external OWN PHP CODE above the theme, right ?

I've been trying to use {CUSTOM_HEADER} as a template containing php code, it doesn't work, I've been trying to link to php files, it doesn't work... well any idea ?

All the documentation talks about modyfing HTML on templates, but not on adding PHP code.

Please help me.
Title: Re: Adding Php to templates
Post by: Nibbler on February 07, 2006, 10:07:30 PM
It will work as a custom header. If you want support you need to provide more information than 'doesn't work'.
Title: Re: Adding Php to templates
Post by: gflogic on February 07, 2006, 11:25:41 PM
Ok I am using the database created by my forum Invision Board 2.1.4.
I am using IPBSDK (http://ipbsdk.sourceforge.net/) to get data from the database to implement tools on my website, so my users don't have to log twice : once they're logged, they're logged on any part of the website would it be member zone, forum, files, etc. ...

Thanks to the bridge apply of Coppermine, now people can add comments under each photo as they are logged under coppermine with the same account they use for the rest of the website.

However, there is a member bar on my website and I want it to be displayed under Coppermine through the theme I am customizing. This way I need to include the SDK (which calls to the forum datas) and pick up data thanks to classes made for that (get login, get private messages, etc. ...)

Code should look like this :


<?php
require_once "../interface/ipbsdk_class.inc.php";
$SDK =& new IPBSDK();
include (
"../serveur.php");
if (
$SDK->is_loggedin()) {
}
else {
if (
$_SERVER['REQUEST_METHOD'] == "POST") {
// le formulaire est envoyé, laissez authentifier

$username $_POST['username'];
$password $_POST['password'];
$remember $_POST['remember'] ? "1" "0";

if ($SDK->login($username$password1"0"$remember)) {
header('location: index.php');
}
else {
}
}
else {
}
}
?>


How could I put it into my theme or the main Coppermine script files ?

By the way, I might not be using the right words or making tough grammar/spelling mistakes : english is not my first language (I'm french) and I'm trying to do my best to be understandable but if there was anything I wrote that was not clear, please ask me.
Title: Re: Adding Php to templates
Post by: Nibbler on February 07, 2006, 11:29:24 PM
OK, then all you need to do is place that code in a file eg. footer.php, place it in your coppermine folder, and then enter footer.php into config as a custom footer ('Path to custom footer include').
Title: Re: Adding Php to templates
Post by: gflogic on February 08, 2006, 12:20:30 AM
Yeah I did that before but it didn't work and I can't figure it out...

Plus, I'm restricted to 2 files/portions of code ? To keep your example : header.php and footer.php ?

How can I place php code as I want, anywhere and as much places as I want ?

Thks
Title: Re: Adding Php to templates
Post by: Nibbler on February 08, 2006, 12:31:45 AM
Themes are not designed to contain masses of custom php code, they are designed to allow visual changes via html/css modification. To have extra php you can use multiple custom headers/footers the 'old' way.

http://coppermine-gallery.net/demo/cpg13x/docs/faq.htm#customHeader

You'll need to copy the pageheader function from include/themes.inc.php into your theme's theme.php and then modify your copy.

Pageheaders are those where you place the {PLACEHOLDER} tag before the {GALLERY} tag, pagefooters are the opposite.
Title: Re: Adding Php to templates
Post by: gflogic on February 08, 2006, 01:03:02 PM
Ok I got it. It doesn't work because the SDK and the bridge of Coppermine can't co-exist. Either one or the other will work seperately, but not the two at the same time.

The idea would be to bridge Coppermine to the SDK and not directly to the forum.

I think I will make, as much as I can, a bridge by myself with the SDK.