Adding Php to templates Adding Php to templates
 

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]

Main Menu

Adding Php to templates

Started by gflogic, February 07, 2006, 12:26:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gflogic

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.


gflogic

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.

Nibbler

It will work as a custom header. If you want support you need to provide more information than 'doesn't work'.

gflogic

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.

Nibbler

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').

gflogic

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

Nibbler

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.

gflogic

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.