Adding php anywhere in the template. Adding php anywhere in the template.
 

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 anywhere in the template.

Started by jeremed, January 11, 2004, 07:57:17 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jeremed

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.

Joachim Müller

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"

Burpee

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:

  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

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.

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

Rhett


Joachim Müller

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

GauGau

Morty

Quote from: Burpee 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:

  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.
//$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.

<?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