Open kerepuki opened 1 week ago
If ALLOW_PHP
is set to false then the php code is not removed in save.php
.
The php code is probably stripped by the browser, you can log $_POST['html']
and see what the browser sends or check the request data in network tab from developer tools (F12 key).
If you wish to keep php code in the page (not recommended) you can use something like <script type="text/php">
for the tags instead of <?php
.
I assume it is because when the page loads in the editor, PHP is executed and the output is HTML.
Take a simple variable declaration
<?php
$number = 1;
?>
If the suggested approach is not recommended, how can I retain the PHP code within my files?
You should use a template system like twig or blade, with php the user can insert any code and you expose your app to arbitrary code execution.
I use Vtpl https://github.com/givanz/vtpl myself inside Vvveb CMS https://github.com/givanz/Vvveb for pages edited by VvvebJs.
Vtpl uses html attributes for templating it does not use a template language and it was designed to be used for such cases where the html can be safely edited by page builders or html editors.
If you still wish to use php convert/replace php <?php
tags to <script type="text/php">
before loading the page in VvvebJs and convert them back to <?php
on page save.
This may seem like two issues but they're both related to the save function.
My HTML files are actually PHP files. These files contain include statements to get headers, footers, global elements etc. When I save the file, even with ALLOW PHP set to true, the saving method strips away all the PHP code.
Also when saving, the nav bar seems to be replicated outside the header section. Sample code below.