There have been various problems including PHP in files before, but I haven’t come across an issue quite like this one. I’ve only just encountered the problem but the issue might have been introduced before 2.6.1.
But it wasn't an issue when I created the site in question. I could save pages without any problem then - not very long ago. I'm sure I did everything in Wappler.
I was adding some Google Analytics code, which I had put in an include. I think it's recommended that this code is included before any other css/js. I thought I would add the Javascript code in directly, but the code was rewritten anyway, because I had already used an include. I'll have to add a lot of extra lines unnecessarily to each page in this site to be able to use it in Wappler. For the time being I'll use a text editor and just add the extra line.
Google Analytics code shouldn’t be in your head but at the end of the body.
The PHP Include in the head won’t be fixed soon as we will need to rewrite our whole html parsing and synchronization with code view. We do plan to eventually use a different HTML5 parser that isn’t that strict (comments/text nodes like PHP aren’t valid in HTML5 …) but it will take time to implement.
The owner of the website concerned is using Google Tag Manager. He sent me the code which, according to Google's documentation, should be placed in the <head> section:
I have the same question. Why not using SSI include? I don´t understan the difference between PHP include and SSI include (and I´ve read the posts about the difference).
From what I understood about the difference, I´ve concluded that activating SSI includes on a server is not convinient or hard to do.
PHP includes in the head section no longer cause the layout to be messed up. This is a great improvement and will be really helpful.
However, there are still issues using Wappler with non-Wappler sites. Eg saving a file containing this line: <a href="stock_detail.php?stockid=<?php echo($rs_stock->getColumnVal('stock_id')); ?>">
… results in: <a href="stock_detail.php?stockid=+++++++++++++++++++++++++++++++++++++++++++++++++++">
It would be nice to be able to edit any PHP in Wappler, but it’s not much of an issue as it only affects old sites obviously. (It was quite an issue on the occasions I’ve forgotten, and have uploaded a page with quite a lot of PHP like this.)
Nothing is actually lost now, which is great - but it’s just encoded when it shouldn’t be:
Eg this line: <link href="css/custom.css?<?php echo filemtime('css/custom.css');?>" rel="stylesheet">
… becomes: <link href="css/custom.css?%3C%3Fphp+echo+filemtime%28%27css%2Fcustom.css%27%29%3B%3F%3E" rel="stylesheet">
… when the document is saved.
However, in some cases, the original line is not changed: <?php echo($rs_stock_featured->getColumnVal('title')); ?>
… but similar lines are changed, when they are enclosed in <a> tags: <a href="stock_detail.php?stockid=<?php echo($rs_stock->getColumnVal('stock_id')); ?>">
…becomes: <a href="stock_detail.php?stockid=%3C%3Fphp+echo%28%24rs_stock-%3EgetColumnVal%28%27stock_id%27%29%29%3B+%3F%3E">