PHP Code into a Template PHP Code into a Template
 

News:

CPG Release 1.6.27
change DB IP storage fields to accommodate IPv6 addresses
remove use of E_STRICT (PHP 8.4 deprecated)
update README to reflect new website
align code with new .com CPG website
correct deprecation in captcha

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