Code rewriting issue when PHP include is in <head> section

investigating

#1

There was a recent thread concerning problems with code rewriting in the <head> section. (I don’t think the thread is available any longer .)

I think I’ve come across something which triggers this. I was reorganising the lines in the <head> section of a page and saved the file - there were no problems: the new order etc. was retained and nothing was altered (even spaces were left intact). I then put a block of lines relating to favicons into an include file and added the relevant PHP include. At this point, all sorts of changes were made: lines were rearranged (js and css files in a seemingly random order), some file references were moved to the <body> section and type="text/javascript" was added to each <script> tag.

I created the include file manually - I don’t think it’s possible to create an include using the Wappler feature in cases like this. I thought perhaps Wappler didn’t recognise the include because the comment Wappler adds was missing. I added it - it made no difference. I also tried changing the App root to the page instead of the body - again, it didn’t help.

I’ve repeated this several times with different pages and including a PHP files causes a problem each time - if I remove it, the rewriting doesn’t happen. Sometimes only minor changes are made - eg moving css files around (but in one case moving the bootstrap css below a custom css file - which could cause a few problems). This seems like a bug.


#2

#3

In case it’s helpful, here is some more information about this issue.

I tried reverting to v1.7.1 but that didn’t help. However, I’m sure it wasn’t a problem until quite recently; I’ve used PHP includes in the <head> section in a number of pages without any problem.

I thought a temporary solution might be to remove the include, edit the document and close it (in Wappler). Then edit the file in separate text editor and put the include back. Unfortunately Wappler reformats the document as soon as it’s opened, this time moving the head and body tags to the wrong place - above the links to the css and js files, eg:

image


#4

Thanks will check it out


#5

#6

Thanks George.