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

Author Topic: Adding php anywhere in the template.  (Read 14605 times)

0 Members and 1 Guest are viewing this topic.

jeremed

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 22
Adding php anywhere in the template.
« on: January 11, 2004, 07:57:17 am »

It would be really nice if php could be added anywhere in the template. I know that you can use the anycontent block, but you can only lay out things vertically with it. I have my template set up in columns. If I could add scripts to the columns, that would be awesome.

I used 4images on another site. There was some bit of code that could be added to one of the config files so that the template could run php. I think it still had a .html extension though. It's been a while.
« Last Edit: September 19, 2005, 10:53:14 pm by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Adding php anywhere in the template.
« Reply #1 on: January 11, 2004, 10:53:03 am »

this has been requested before, but can't be done that easily. The theming system will have to be re-worked completely for this - don't expect this in the next time: maybe it'll be in a future version (distant future).

GauGau

P.S. The extension "html" of the template file really doesn't matter at all. the theming system has been "borrowed" from phpBB - they use the extension "tpl"
Logged

Burpee

  • Contributor
  • Coppermine regular visitor
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 71
    • Vuurwerklook.com
Re: Adding php anywhere in the template.
« Reply #2 on: April 30, 2004, 02:47:10 pm »

I found a post about this a while ago fixing this for me.

in CPG 1.2.1, you can do this by going into functions.inc.php
and looking for $template = fread(fopen($template_file, 'r'), filesize($template_file));
replace this line with:
Code: [Select]
  ob_start();                     // Start output buffering
  include ($template_file);       // Parsed file goes to buffer
  $template = ob_get_contents();  // Assign buffer to $template
  ob_end_clean();                 // Clear buffer and turn off output buffering

I can't remember who made this, but it worked perfectly for me.

Rhett

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
PHP Include Header
« Reply #3 on: July 14, 2004, 11:24:57 am »

Hi, I looked at http://forum.coppermine-gallery.net/index.php?topic=2988.0 and did that, and this is my code I replaced that line with.

Code: [Select]
ob_start();                     // Start output buffering
include ('http://www.firstaog-youth.com/header.php');       // Parsed file goes to buffer
$template = ob_get_contents();  // Assign buffer to $template
ob_end_clean();                 // Clear buffer and turn off output buffering

THe header is appearing, but at the bottom, and the menu isn't appearing at the top.

http://www.firstaog-youth.com/photoalbum/ is the location of the CPG. I have version 1.3.0

Help is appreciated.

Brett
Logged

Rhett

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: PHP Include Header
« Reply #4 on: July 18, 2004, 01:59:51 am »

any thoughts?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Adding php anywhere in the template.
« Reply #5 on: July 18, 2004, 08:48:44 am »

merged Rhett's question with the thread his question is refering to.

GauGau
Logged

Morty

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Adding php anywhere in the template.
« Reply #6 on: September 19, 2005, 07:52:22 pm »

I found a post about this a while ago fixing this for me.

in CPG 1.2.1, you can do this by going into functions.inc.php
and looking for $template = fread(fopen($template_file, 'r'), filesize($template_file));
replace this line with:
Code: [Select]
  ob_start();                     // Start output buffering
  include ($template_file);       // Parsed file goes to buffer
  $template = ob_get_contents();  // Assign buffer to $template
  ob_end_clean();                 // Clear buffer and turn off output buffering

I can't remember who made this, but it worked perfectly for me.

Give me your address, I'm sending over 5 strippers now!    THANK YOU THANK YOU THANK YOU!   That worked perfect.

But to add to your post........

Do not REPLACE that code people, just make it non functional by putting the two slashes infront of it.  That way the code is not lost.
Code: [Select]
//$template = fread(fopen($template_file, 'r'), filesize($template_file));
Should be able to find this line around 376 in version 1.3.4

The other part that might help people out, is with this code change pointed out by Burpee, you can do php includes straight into your template file now.  Instead of trying to get it to work with editing the theme.php.  Which is a real pain in the butt.

Code: [Select]
<?php include('YourIncludedFileLocationHere.php'); ?>
Thanks again Burpee!  I know you found it but I still thank you.  Just allowed me to finally move forward with my site.  I've been on hold while I sorted this out.   ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 22 queries.