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 in template with scripts  (Read 6549 times)

0 Members and 1 Guest are viewing this topic.

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
php include in template with scripts
« on: August 26, 2005, 02:52:02 am »

i've learned how to use custom_headers and got the basic idea.. but it seems like the only thing i'm able to include is straight up html.. i'm sure i'm just lacking the knowledge required... i've searched through a lot of threads already and most of them just get custom_header working i want to go to the next step...

I'd like to get this working inside my template or include it somehow using custom_header... like i said the only thing i've been able to include is straight up html.

<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/");

$styleguide = array(
      "alttag" => "%w %t - %h hits",
      "imagestyle" => "photoclip",
      "imagesize" => 'thumb');   

$objCpm->cpm_viewRandomTopRatedMediaFrom("",6,1,$styleguide);
$objCpm->cpm_close();
?>

if you could point me to another thread or have an idea what to search for in the forums that would help a lot.
Logged

Nibbler

  • Guest
Re: php include in template with scripts
« Reply #1 on: August 26, 2005, 03:02:27 am »

Post cpmfetch questions on the cpmfech thread, just like any other mod.
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #2 on: August 26, 2005, 03:16:24 am »

no this isn't a problem with cpmfetch.. that's just an example of a piece of code i want to get working inside the custom_header but don't know how

that bit of cpmfetch code works perfectly fine
Logged

Nibbler

  • Guest
Re: php include in template with scripts
« Reply #3 on: August 26, 2005, 03:17:59 am »

OK, so post your code that does not work.
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #4 on: August 26, 2005, 03:42:21 am »

i have this which i editted in theme.php... and this all works.. i think anyway..


Code: [Select]
function pageheader($section, $meta = '')
{
  global $CONFIG, $THEME_DIR;
  global $template_header, $lang_charset, $lang_text_dir;
 
  if(empty($custom_header)){
     include('highest_rated.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);
}

and then in the file highest_rated.php i have this
Code: [Select]
*** HTML ***

<?php
include "./cpmfetch/cpmfetch.php";
$objCpm = new cpm("/");

$styleguide = array(
"alttag" => "%w %t - %h hits",
"imagestyle" => "photoclip",
"imagesize" => 'thumb');

$objCpm->cpm_viewRandomTopRatedMediaFrom("",6,1,$styleguide);
$objCpm->cpm_close();
?>


*** Closing HTML ***

i get this error

Fatal error: Call to a member function on a non-object in /home/tpimp/public_html/themes/trendpimp/theme.php on line 965
Logged

Nibbler

  • Guest
Re: php include in template with scripts
« Reply #5 on: August 26, 2005, 03:55:04 am »

Change this:

Code: [Select]
include "./cpmfetch/cpmfetch.php";
to this

Code: [Select]
require "./cpmfetch/cpmfetch.php";
Then you should get an error message that will help you sort out the correct path to use.
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #6 on: August 26, 2005, 03:59:13 am »

i'm still getting the same error
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #7 on: August 26, 2005, 04:00:07 am »

this is  line 965

Code: [Select]
        $main_menu = $ns -> tablerender($CONFIG['gallery_name']." - ".$CONFIG['gallery_description'], $main_menu);
Logged

Nibbler

  • Guest
Re: php include in template with scripts
« Reply #8 on: August 26, 2005, 04:01:31 am »

That's not Coppermine code, I can't help you with that.
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #9 on: August 26, 2005, 04:12:05 am »

the CPM Fetch stuff or that line i pasted..

everything here is from theme.php and i've barely modded theme.php the only things i've changed around are the html layout...
Logged

Nibbler

  • Guest
Re: php include in template with scripts
« Reply #10 on: August 26, 2005, 04:17:14 am »

The line you posted is not Coppermine code, it must be e107 code which I know nothing about. The e107 port is not supported here.
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #11 on: August 26, 2005, 04:36:35 am »

this post i accidently posted somewhere else.. real sorry guys didn't mean to make a mess of your forums

i remember way back in the day porting from e107 to coppermine and i mist have accidently copied that code over and made everything go wonky... i rebuilt another theme.php and i don't get any errors... the only thing now is when i try to use {CUSTOM_HEADER} it just shows up as {CUSTOM_HEADER} and doesn't include anything.. but i think i remmeber reading about that on the forums.. if i find a thread that solves my problems i'll link it here

thanks for your help nibbler
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #12 on: August 26, 2005, 04:40:42 am »

ok now i get this

Fatal error: Cannot instantiate non-existent class: cpm in /home/tpimp/public_html/highest_rated.php on line 15

and line 15 is this

Code: [Select]
$objCpm = new cpm("/");
Logged

Nibbler

  • Guest
Re: php include in template with scripts
« Reply #13 on: August 26, 2005, 04:44:18 am »

Right, that means the file containing cpmfetch was not included. Check the path to it is correct. You can enter a full server path if you are unsure.
Logged

smoke10010

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 24
Re: php include in template with scripts
« Reply #14 on: August 26, 2005, 10:13:01 am »

Instead of custom_header showing up i get a {CUSTOM_HEADER} popping up and not the actual content

this is the code i'm using

Code: [Select]
function pageheader($section, $meta = '')
{
  global $CONFIG, $THEME_DIR;
  global $template_header, $lang_charset, $lang_text_dir;
 
  if(empty($custom_header)){
     include('highest_rated.php');
     /*static*/ $custom_header = ob_get_contents();
     ob_clean();
  }

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    header("Content-Type: text/html; charset=$charset");
    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);
}

why is it not displaying as the content within highest_rated.php and instead just displaying {CUSTOM_HEADER}

Logged

Nibbler

  • Guest
Re: php include in template with scripts
« Reply #15 on: August 26, 2005, 04:12:10 pm »

Make sure the {CUSTOM_HEADER} comes before the {GALLERY} in your template.html. If it comes afterwards then you need to treat it as a custom footer instead.
Logged
Pages: [1]   Go Up
 

Page created in 0.054 seconds with 20 queries.