PHP Code into a Template PHP Code into a 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 Code into a Template

Started by kraftworkz, March 12, 2007, 10:27:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kraftworkz

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.

nickfzx

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

kraftworkz

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');
}
?>


nickfzx

search this forum for "universal login" or "login box"... something along those lines...this has been discussed before.

kraftworkz

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');
}
?>