PHP inside HTML

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Suggested Hosts
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
User avatar
Surreal09
Registered User
Posts: 52
Joined: Mon Mar 02, 2009 9:44 pm

PHP inside HTML

Post by Surreal09 » Mon Jun 22, 2009 2:31 pm

Is it possible for me to put some php code inside of a .html template file?

I am creating a new page for my Rules/About Us etc for my website using a guide in the KnowledgeBase. I want to add this code:

Code: Select all

<?php
if ($user->data['user_id'] == ANONYMOUS)
{
   echo 'Please login!';
}

else
{
   echo 'Thanks for logging in, ' . $user->data['username_clean'];
}
?>
Maybe not exactly that, I mightput something different but along the lines of that code, can I add it to my rules_body.html file?? When I add it under the Include overall_header bit at the top, it doesn't work for me. Any ideas how I can get this to work?

Regards.

User avatar
Erik Frèrejean
Former Team Member
Posts: 9899
Joined: Tue Oct 09, 2007 9:09 am
Location: The Netherlands, 3.0.x Support Forum
Name: Erik Frèrejean
Contact:

Re: PHP inside HTML

Post by Erik Frèrejean » Mon Jun 22, 2009 3:18 pm

Yes that is possible, but you'll have to use the PHP template block for that. Also see the Template Syntax article for that. Before you can use php in template you'll need to enable it through the security settings in the Admin Control Panel.
Support Toolkit | Support Request Template | Knowledge Base | phpBB 3.0.x documentation
I don't give support via PM or IM! (all unsolicited pms will be trashed!)

User avatar
Surreal09
Registered User
Posts: 52
Joined: Mon Mar 02, 2009 9:44 pm

Re: PHP inside HTML

Post by Surreal09 » Mon Jun 22, 2009 3:42 pm

So would this be it:

Code: Select all

<!-- INCLUDE overall_header.html -->

<!-- PHP -->
if ($user->data['user_id'] == ANONYMOUS)
{
   echo 'Please login!';
}

else
{
   echo 'Thanks for logging in, ' . $user->data['username_clean'];
}
<!-- ENDPHP -->

    <h2>Rules</h2>

<div class="panel">
   <div class="inner"><span class="corners-top"><span></span></span>

     <div class="content">
          <p>
             Test Rules Here
             
             More TEST
             <ul>
                <li>TEST</li>
                <li>123</li>
                <li>bleh</li>
             </ul>
          </p>
   	 </div>

   <span class="corners-bottom"><span></span></span></div>
</div>

<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->

Locked

Return to “[3.0.x] Support Forum”