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: php include on template?  (Read 4572 times)

0 Members and 1 Guest are viewing this topic.

lisah

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
php include on template?
« on: May 30, 2005, 04:50:37 pm »

Is there any way of getting a script like so to work on the template page:

Code: [Select]
<?php include "http://www.3skimo.com/paul/randomimage.php"?>
I had a random image appearing in the left column throughout the site and for that to happen I need to use that bit of code. ^ However when I try to insert it on the template nothing happens.

(http://www.3skimo.com/paul/gallery/ click through the navigation for an example of what I mean)

« Last Edit: June 09, 2005, 08:26:21 am by GauGau »
Logged

Nibbler

  • Guest
Re: php include on template?
« Reply #1 on: May 30, 2005, 04:52:43 pm »

Use a custom header/footer as described in the docs.

Also update your gallery.
Logged

lisah

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: php include on template?
« Reply #2 on: May 30, 2005, 05:13:09 pm »

I copied:

Code: [Select]
function pageheader($section, $meta = '')
{
   global $CONFIG, $THEME_DIR;
   global $template_header, $lang_charset, $lang_text_dir;

   if(empty($custom_header)){
      include('/path/your_file.php');
      static $custom_header = ob_get_contents();
      ob_clean();
   }

   header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
   user_save_profile();

   $template_vars = array(
      '{LANG_DIR}' => $lang_text_dir,
      '{TITLE}' => $CONFIG['gallery_name'].' - '.$section,
      '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
      '{META}' => $meta,
      '{GAL_NAME}' => $CONFIG['gallery_name'],
      '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
      '{MAIN_MENU}' => theme_main_menu(),
      '{ADMIN_MENU}' => theme_admin_mode_menu(),
      '{CUSTOM_HEADER}' => $custom_header,
   );

   echo template_eval($template_header, $template_vars);
}

into theme.php and changed the line:

Code: [Select]
include('/path/your_file.php');
to

Code: [Select]
include('http://www.3skimo.com/paul/randomimage.php');
Then I got this:

Parse error: parse error, unexpected '(', expecting ',' or ';' in /home/3skimocom/public_html/paul/gallery/themes/pgallery/theme.php on line 810

What did I do wrong?

Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: php include on template?
« Reply #3 on: May 31, 2005, 05:55:44 am »

what is line 810 for you? If the include is on your server, don't use http include, but use the relative or absolute path (not related to your error message though)
Logged

Dr0xX3rZ

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: php include on template?
« Reply #4 on: June 02, 2005, 10:46:22 pm »

I'm trying to do EXACTLY the same thing on http://www.photorosemont.cjb.net

I want the random image to go where there a {RANDOM} tag... can't get it to work :(
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: php include on template?
« Reply #5 on: June 02, 2005, 11:38:54 pm »

your issue differs, and you already posted about your issue. Don't cross-post! >:(
Logged

bit bit spears

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 240
    • TangibleBrit.com
Re: php include on template?
« Reply #6 on: June 03, 2005, 06:12:24 am »

lisah: Please post the exact code of your entire theme.php file and template.html in here so i can review and help you solve your issue.
Logged

onr

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 13
    • Chocolate Fish Photos
Re: php include on template?
« Reply #7 on: June 06, 2005, 06:34:36 pm »

I have exactly the same problem (and the same error message as Isah). I am trying to include a different text file between two <td> tags which in normal html I used to do with
Code: [Select]
<?php include("file.txt"); ?>

I want the filename to be dependent on which language is chosen. So for starters I tried to include a file with a
fixed filename as gaugau suggested in the pageheader function in theme.php.
I then tried to insert this variable (called INTRO) in
Code: [Select]
$template_cat_list = <<<EOT
<!-- BEGIN header -->
<tr><td class="tableh2" align=center colspan="3">
             <table>
              <tr>
               <td class="table_info" width="100%">              
               {INTRO}                              
        </td>
              </tr>
             </table>              
        </td></tr>        
        <tr> <td> &nbsp; </td> </tr>
        <tr>
                <td class="tableh1" width="100%"><b>{CATEGORY}</b></td>
               
        </tr>
<!-- END header -->
but first of all I got the same error message as Isah from the pageheader funciton which I can get rid of if I remove the round brackets at the end of
Code: [Select]
static $custom_header = ob_get_contents();
but still in the place where the text read into the INTRO variable should appear, I simply get: {INTRO}.
Any help would be much appreciated. ???
Logged

onr

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 13
    • Chocolate Fish Photos
Re: php include on template?
« Reply #8 on: June 08, 2005, 02:01:49 pm »

Error message sloved:
move the static statement into the header.
Originally the suggestion was:
Code: [Select]
global $CONFIG, $THEME_ DIR;
global $template_header, $lang_charset, $lang_text_dir;
   
    if(empty($custom_header)){
      include('random.php');
      static $custom_header = ob_get_contents();
      ob_clean();
   }

if you change this to

Code: [Select]
global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;
    static $custom_header;
   
    if(empty($custom_header)){
      include('random.php');
      $custom_header = ob_get_contents();
      ob_clean();
   } 
it will work ...  ;)
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.