DataView or Notify within Include File not working ? How to solve

I just realized that some components like DataView and Notify doesnt work if its stored as external include PHP.

For Example i have a page like dashboard.php and i put some stuff like userinformations into a userinfo.php and having there notify or detail view, doesnt work. Whats the proper way to work? I played around with APP Type : Body or Header, but same results:

Hello Freddy,
Probably the js files for these components are not included in your page <head> tags.

@Teodor okay means I should also include them in my example userinfo.php where I got that error? I want to prevent, that I got these js files twice. (in dashboard.php which includes userinfo.php). How you solve that?

This type of problem is not something specific to Wappler @Freddy_Blockchain, this would cause the exact same issue on any development environment, you have to include all the external libraries of every single page that uses them.

Let’s just take a simple example.
You add a new page, add App Connect Framework which adds the dmxAppConnect.js file to the head of the html file.
You add Bootstrap 4 Framework as a CDN to your page, and it adds jquery-3.3.1.slim.min.js, font-awesome.min.css, bootstrap.min.css all to the html document head. Just before the closing body tag it also adds popper.min.js, and bootstrap.min.js

These are all the supporting external libraries that need to be present in the base html document on every single page in order for App Connect, Font Awesome, Bootstrap 4.x and jQuery to work as expected.

If you now add something like a navigation component to your base html page, then it auto adds the relevant supporting external library of dmxBootstrap4Navigation.js once again to the document head section.

So far this would be similar in Wappler or Dreamweaver or hand coding any page for that matter. Now you want to move your NavBar to an external PHP Include file, so you select your Nav component in the App Structure which only selects from

<nav class="navbar navbar-expand-lg navbar-light">
  ...TO
</nav>

And places all that code into an external include file, and at the first line of the external include file it adds a commented out line like

<!-- Wappler include  appconnect="local" bootstrap4="cdn" jquery_slim_33="cdn"-->

Which is only so Wappler can render the file correctly in design view when the include file is opened all by itself otherwise include files would never render in design view, this commented out code does not tell the include to add those libraries to every page it is included on.

So now if you are finished with your websites first master page and you want to create the next page, when you create a new file, you will need to make sure to add all the supporting libraries to the page, such as your 2 frameworks, as well as a false navbar to get the head library to add, then delete the navbar you just added and add you include instead. Wappler can not do it for you.

Please Note with the navbar, you can include the supporting js library in the include, but this is just an example which I used the navbar as the subject.

Just like in PHP, an include can not add a single part into the body tag and another part into the head tag, so you have to manually add the supporting head tag libraries in every single file.

Even Google can not get around this issue, look at the difference in Google Analytics libraries, the older analytics.js code snippet was added to the last line just before the closing body tag, and could be used as an external include file. The newer gtag implementation gets added as the first line after the opening head tag, and they tell you to manually add the exact same script to every single page of your site, as there is no simple way to add it as an include file.

Basically, moral of this story is that, this is not a Wappler design flaw, but rather normal behaviour for include files, which for argument sake Wappler could possibly find a way around for us more than likely, but they would be fixing an include flaw and not really a Wappler one as such.

Just my opinion…

3 Likes

@psweb thank you alot for such a deep constructive answer. Not only helps me, but also other users in general about that topic. I try now to figure out what’s the best solution as I know the fundamentals now, which isn’t a wappler topic - as most questions here :slight_smile: .

2 Likes