forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Themes/Skins/Templates => Topic started by: lisah on May 30, 2005, 04:50:37 pm

Title: php include on template?
Post by: lisah 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)

Title: Re: php include on template?
Post by: Nibbler on May 30, 2005, 04:52:43 pm
Use a custom header/footer as described in the docs.

Also update your gallery.
Title: Re: php include on template?
Post by: lisah 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?

Title: Re: php include on template?
Post by: Joachim Müller 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)
Title: Re: php include on template?
Post by: Dr0xX3rZ 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 :(
Title: Re: php include on template?
Post by: Joachim Müller on June 02, 2005, 11:38:54 pm
your issue differs, and you already posted about your issue. Don't cross-post! >:(
Title: Re: php include on template?
Post by: bit bit spears 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.
Title: Re: php include on template?
Post by: onr 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. ???
Title: Re: php include on template?
Post by: onr 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 ...  ;)