forum.coppermine-gallery.net

Support => cpg1.6.x Support => cpg1.6 themes (visuals) => Topic started by: Hanna. on June 20, 2019, 05:56:13 pm

Title: PHP include not picking up in template.html
Post by: Hanna. on June 20, 2019, 05:56:13 pm
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:
Code: [Select]
<?php include("disclaimer.php"); ?>
The file is online and ready to be picked up (see link (https://laurenconrad.org/gallery/themes/2019june/disclaimer.php))

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)

Code: [Select]
<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

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


</body>
</html>

If I am missing something please tell me.
Title: Re: PHP include not picking up in template.html
Post by: ron4mac on June 20, 2019, 06:46:58 pm
You can not include a PHP file in a .html file.

Describe fully what you are trying to achieve.
Title: Re: PHP include not picking up in template.html
Post by: 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?
Title: Re: PHP include not picking up in template.html
Post by: ron4mac on June 21, 2019, 02:15:28 pm
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
Title: Re: PHP include not picking up in template.html
Post by: phill104 on June 21, 2019, 11:46:03 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?
Title: Re: PHP include not picking up in template.html
Post by: Hanna. on June 25, 2019, 12:54:58 am
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.
Title: Re: PHP include not picking up in template.html
Post by: 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.
Title: Re: PHP include not picking up in template.html
Post by: Hanna. on June 27, 2019, 01:27:13 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!!!