php include in template with scripts php include in template with scripts
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

php include in template with scripts

Started by smoke10010, August 26, 2005, 02:52:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

smoke10010

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.

Nibbler

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

smoke10010

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

Nibbler

OK, so post your code that does not work.

smoke10010

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


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

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

Nibbler

Change this:

include "./cpmfetch/cpmfetch.php";

to this

require "./cpmfetch/cpmfetch.php";

Then you should get an error message that will help you sort out the correct path to use.

smoke10010


smoke10010

this is  line 965

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

Nibbler

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

smoke10010

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

Nibbler

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.

smoke10010

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

smoke10010

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

$objCpm = new cpm("/");


Nibbler

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.

smoke10010

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

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}


Nibbler

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.