I am new to Twig Symfony and trying to implement an existing PHP project with Twig in order to separate HTML and PHP in the code.
Basically, I created an index.html to render content in the index.php, however, my original index.php includes some other PHP files like this
include("patientModal.php");
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<?php include(ROOT."controllers/NavbarFormLoad.php"); ?>
</div>
The NavbarFormLoad.php is like below
<?php
session_start();
$path = ROOT."html/data/forms";
foreach(new DirectoryIterator($path) as $fileInfo){
if($fileInfo->isDot()){
continue;
} else {
$filename_noex = preg_replace('/\\.[^.\\s]{3,4}$/', '',
$fileInfo->getFilename());
$filename_whitespace = str_replace("_", " ", $filename_noex);
echo '<a class="openmrs-dropdown-form dropdown-item" onclick="handleDropdownSelect(\''.$filename_noex.'\')">'.$filename_whitespace.'</a>';
}
}
?>
Can I do this in my new index.php in order to pass those forms?
//create a variable $NavFormLoad
$forms = [
'Nav' => include(ROOT."controllers/NavbarFormLoad.php"),
'Patient' => include("get/GetSelectedPatient.php"),
'Location' => include("get/GetSelectedLocation.php")
];