I’m still getting used to Wappler - I like what I see, but before I grow the application too far I’d like to understand what is the best way to manage common components used on a page? In a standard app, I’d just move everything into a number of includes, but that doesn’t seem to be so obvious with Wappler…
For example, I have a navbar which I’ve moved into an include - it works, but I need some Server Connect modules to make it really usable to (for example) update the menu depending on the logged in state of the user. It doesn’t seem possible to add this to the include, so it seems I can really only use the navbar with dynamic features if it’s not in an include, but then I need to manage it on dozens of pages.
If I include a navbar in an include, then it is not editable using Wappler - I can edit the html directly, but I can’t edit it visually, or add any of the Wappler special sauce.
If I add the markup at the top of the include to make it an app, then I can edit it in Wappler, however this doesn’t actually work since I then get runtime errors since these includes are already loaded and can’t be loaded again. The specific error that pops up is something like “App is already running”.
Maybe there’s another way to do this, or I’m missing the point somewhere so I’d welcome further information on how to achieve this.
You can open your include in Wappler and edit it directly.
Are you sure you create your include in Wappler as per docs, and not just copy-pasting code in an empty php file?
Unfortunately this doesn’t seem to work as I’d hoped. If I edit using the button in the SSI component, then I can visually edit the NavBar, however it seems that it doesn’t allow me to add any Server Connect components, and it also seems that there are no dynamic attributes that can be set.
For example, if I add a Header element directly to the main file, then I have a bunch of dynamic features I can set…
I was using php on both, but then decided to start with a fresh example. I've now renamed these all the php, and it doesn't seem to make a lot of difference.
Was the app connect framework included on the parent/main page before creating the serverside include?
It should not show ‘body’ in the structure but ‘app’ if app connect is added on the main/parent page.
Remember that the App Connect framework is required for almost all the components and functionality in Wappler.
@Teodor one issue I’ve come across here is that when I add components into my included file, they are added with relative URLs. This works fine if the page is in the same folder as the include, but not when it’s in another folder.
Eg - I have a /navbar.php include file. This is included into /index.php so everything works fine. However, when I use the same include in /other/index.php, it doesn’t work since any components are included as relative links -:
I can of course edit this to make it an absolute reference and that works fine in all pages, but it seems that this should be handled better by Wappler?