PHP include not picking up in template.html PHP include not picking up in template.html
 

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 not picking up in template.html

Started by Hanna., June 20, 2019, 05:56:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hanna.

Hey guys - I am trying to make things easier for myself (with many coppermine installations) to now start using PHP include so I can finally have "flat" template.html's and edit the php files for manual corrections.

However, the general code for PHP include that I am trying to set up is:
<?php include("disclaimer.php"); ?>

The file is online and ready to be picked up (see link)

The template.html and disclaimer.php are located in the theme folder together.

disclaimer.php inside looks like this: (if relevant to fix this issue)

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php
echo "Hello World!";
?>


</body>
</html>


If I am missing something please tell me.

ron4mac

You can not include a PHP file in a .html file.

Describe fully what you are trying to achieve.

Hanna.

I'm trying to include different sections into template.html from other files (with content). You are saying I cannot do that?

ron4mac

HTML can be imbedded in a PHP file, but PHP can not be imbedded in a HTML file.

You could use this (somewhat kludgy) method to include HTML files in your template.html.
https://www.w3schools.com/howto/howto_html_include.asp

phill104

Quote from: Hanna. on June 20, 2019, 06:50:58 PM
I'm trying to include different sections into template.html from other files (with content). You are saying I cannot do that?

Maybe explain in more detail what you are trying to accomplish. HTML is client side, PHP is server side executed. The two can interact. PHP can generate HTML, HTML can send information to PHP. So what output from a PHP file do you want in your HTML?
It is a mistake to think you can solve any major problems just with potatoes.

Hanna.

Quote from: Phill Luckhurst on June 21, 2019, 11:46:03 PM
Maybe explain in more detail what you are trying to accomplish. HTML is client side, PHP is server side executed. The two can interact. PHP can generate HTML, HTML can send information to PHP. So what output from a PHP file do you want in your HTML?

I am trying to use template.html as it comes, with the basics {} codes etc. And keep it as a clean template.

Then I am trying to IMPORT content from other html or php (such as specific texts/images and what not) to display on the template.html as sections. Just as you would import header.php and footer.php to an index.php BUT do it with template.html.

ron4mac

Here is a plugin I put together for you to try. See the README for use instructions.
Only works with inserting HTML. I may later expand it to be able to include PHP ... don't know yet.

Hanna.

Quote from: ron4mac on June 25, 2019, 04:25:26 PM
Here is a plugin I put together for you to try. See the README for use instructions.
Only works with inserting HTML. I may later expand it to be able to include PHP ... don't know yet.

This is precisely what I needed! HTML is perfect! Thank you!!!