Home » Php » Loading a complete HTML Page in Modal Box using php code only

Loading a complete HTML Page in Modal Box using php code only

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have multiple HTML file.
I want to display this file content in modal box base on condition.
I do not want to use iframe and javascript or jquery.
So It is possible from php side only?

Example:

<div class="modal  fade bd-example-modal-lg shopify-onload-popup" id="defaultPopup-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered  modal-lg" role="document">
        <div class="modal-content">
            <?php
            if ($variable == 1) {
                ?>
                <!-- Loade file1.html -->
                <?php
            } else {
                ?>
                <!-- Loade file2.html -->
                <?php
            }
            ?>
        </div>
    </div>
</div>
How to&Answers:

you can use PHP include function like this

  <?php
       if ($variable == 1) {
           include "file1.php";
       } else {
           include "file2.php";
       }
   ?>

Answer:

Why an html template? Include a php page instead of html with include

<?php if ($variable == 1) {
           include ('includes/content-one.php');
        } else {
           include ('includes/content-two.php');
        }
        ?>