php include on template? php include on 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

php include on template?

Started by lisah, May 30, 2005, 04:50:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lisah

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

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


Nibbler

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

Also update your gallery.

lisah

I copied:

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:

include('/path/your_file.php');

to

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?


Joachim Müller

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)

Dr0xX3rZ

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 :(

Joachim Müller

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

bit bit spears

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.

onr

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

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

$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

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

onr

Error message sloved:
move the static statement into the header.
Originally the suggestion was:

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


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