coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: kraftworkz on March 12, 2007, 10:27:58 PM

Title: PHP Code into a Template
Post by: kraftworkz on March 12, 2007, 10:27:58 PM
How can I get PHP code into the template file?

I want to have a global user (phpbb) if statement to show or not to show a link, depending on if there logged in or not.
Title: Re: PHP Code into a Template
Post by: nickfzx on March 12, 2007, 10:49:02 PM
insert this into your template file:


{CUSTOM_HEADER}

where you want the php to appear.

stick this in your theme file just before // Displays a picture:

function pageheader($section, $meta = '')
{
   global $CONFIG, $THEME_DIR;
   global $template_header, $lang_charset, $lang_text_dir;

   if(empty($custom_header)){

   
                                    Put your PHP CODE HERE
   
}



if this isn't clear enough try searching, it is explained in the docs too
Title: Re: PHP Code into a Template
Post by: kraftworkz on March 13, 2007, 04:25:36 AM
Ok, so far so good, Thank you. But now how does CPG check if a user is logged in?


<?php
if( $userdata['session_logged_in'] )
   {
  
echo('some code');
}
else{
echo('some code');
}
?>

Title: Re: PHP Code into a Template
Post by: nickfzx on March 13, 2007, 04:28:09 AM
search this forum for "universal login" or "login box"... something along those lines...this has been discussed before.
Title: Re: PHP Code into a Template
Post by: kraftworkz on March 13, 2007, 05:03:36 AM
Found it, works like a charm. Thank you again..

The result is as follows:


<?php
if (USER_ID)
   {
  
echo('some code');
}
else{
echo('some code');
}
?>