Server side include (php include) - moves include out of <head>

I used includes for stylesheets or any other scripts i might have to use in the future.
So normally the structure would be adding the include above the head… as image below.

Please note im only using / AppConnect nothing else for the testing

But when i save the file. It removes the include file out of the head and place this within the body tag

======== TEMPLATE BUG FORM ========

Wappler Version: 1.9.9
Operating System: windows 7

Sorry it seems you need to use <?php require_once 'stylesheets.php';?> if you want to keep using a include in the but the only problem then is it wont “render” the content in Wappler

As far as I know PHP Includes are used to place reusable content inside a page body and Wappler is keen enough to see that it has to move the include to the body part.
To include custom style sheets you may use “attach style sheet” stylesheet

Yes i hear you … but i use “includes” for “scripts” and “multi stylesheets”.

So that i dont have to go to every single page… its just weird that it moves the “include file tag” back into the body if i placed it above the

stylesheets i would include…

or scripts i would “include” to re-use

I mentioned this or a similar problem quite a while ago - in relation to using a PHP include in the <head> section - eg for meta tags. This does seem to be a problem which should be fixed.

In the case of your javascript example, couldn’t you just use a link to a .js file rather than a .php file?

Hi TomD … thanks for the reply… i did do a search but could not find your topic… maybe my search tags did not correspond with your post

The same goes for my Javascript file. I like keeping the javascripts in files for debugging and easy to change in a file archive. or just script it out… lol… just my silly way of doing this… and not keep 1 very very long js file…

I couldn’t find my post either. Essentialy, it concerned a problem where the code was rewritten on closing/reopening a file, making it impossible to use a PHP include for meta tags - similar to your problem. It seems this is still a problem.

Ok i have the latest version donwloaded now…

V 2.1.5

But still the same problem as explained before. Does anyone else use server side includes above the HEAD tag? or am i the only one…

I’ve found the topic I raised about this in January. I found it by looking in my profile. The topic doesn’t seem to be searchable. I don’t know if this is intentional or a problem with Discourse.

I do, but with the greatest of care. This is one of the instances that works for me

hi Ben… thanks for they reply. The problem is… “include_once” seems not to “render” in design view. Ok let me see test the “include_once” and give feedback.

thanks for the Link TomD … lets hope @patrick or somebody gets back to us on this… as you said… don’t know if this is intentional or a problem with Discourse.

Wappler can’t render PHP code, it renders only the HTML in design view. The only exception are the server-side includes created in Wappler, the HTML from those files are injected in design view to render correctly. Any other PHP includes and/or HTML generated with PHP code will not be rendered/visible in the design view.

I think the main issue is that the code is rewritten, putting the PHP include in the wrong place if it’s added to the <head> section.

Hi Patrick that is fully understood. The main question is as above where it moves the PHP include out of the <head> and back into the <body>

sorry see TomD did just mention that…

It should indeed not be moved out of the head, that is a bug, didn’t know this was still not fixed. Does this still happen in the latest version of Wappler?

Still have the problem on this version above…

We are currently working on fixing this problem. Hope to have it fixed in the upcoming update.

1 Like

Thank you so much guys …Thanks Teodor and Patrick… @TomD

Hello @Teodor, can this be done also for .NET implementation?
Sorry for hijacking this post @Mozzi, everyone. Just want to implement the same for aspx.

1 Like