Still a newbie with Node/Content/Partial/Layouts and have some questions…
Where do I include items such as the local storage manager? Currently I have them in the layout page but when I try to clear the cache for example it fails, so included in the content page which works fine… And how about other features such as Lightbox, Data Store, infact all extensions?
What is the best practice here, as for the life of me can’t find any information on the Community? Is a subject also lacking from the documentation as far as I can see…?
I have worked quite a bit with Layout -> Content -> Partials and yes it can be a bit of a pain.
From my experience its a bit of a manual task to be honest, as I manually make sure in my Layout Page which holds the <head></head> section that I add all components that are common, such as browser, notify, alert, toasts, as all those are just dummy containers that I will dynamically populate with dynamic data, as well as styling, and the browser component, well I normally only have one at the base of the site which I reuse.
Then I may have a few Content pages, honestly not too many, maybe 4 at most, and in those I am storing vastly different layouts, like one is a blog layout, one is a product page layout, etc.
In these if its a fairly small site you can just stick everything and not really worry about partials.
Personally I am a partial fan, so my content pages are generally just full of links to different partial files, each partial contains its own <serverconnct></serverconnect> that are relevant to the content of the partial.
It can at this point be fairly difficult to access the bindings in the pickers as you will not see most of them from the partial file, so I kind of switch between tabs manually getting whats needed, often creating the element first inside the content page, and then moving it to a partial at the end of that section.
So am on the right track mix and matching…? Just thought maybe am doing this all wrong and before things get too large and complex will hit the nail on the head early to try and wrap my small brain around it all.
Can also envisage the same problem with the Data Store… If I remember the app id had to be the same (maybe I am totally wrong), and with content pages etc obviously each is defined by the route by default? Just trying to foresee issues arising, hope this makes sense? I don’t want to run Flows left right and centre, would this be the only alternative route (pardon the pun)? And don’t really want to be calling Local Storage in both the layout and the content pages, as surely this is not correct, and will take up unnecessary resources by repeating requests… Thus lays my confusion and request for the best practice to deploy the above to our application.
The way that I understand that the Node/Express template system works:
When a page is requested, the Layout page (Template) is invoked. The Layout page then inserts the Content page into it.
This means that all components, such as Notification, Browser, Server Connect etc. that are used in multiple Content pages, will need to be placed in the Layout page. If a component is used in one Content page only, you can place that component in the relevant page.
Partials are inserted into the Layout and or Content page as required.
This means that a Partial should be treated as part of the page into which it is inserted, i.e. it makes use of the components of the relevant page.
These are the principles that I base my Node/Express projects on.
As an example, this is my Layout page, where even Modals that are used in multiple pages, have been placed in the Layout page:
Thank you Ben really helpful but am still at a loss with the Data Store and Local Storage components as neither function correctly when contained within the Layout page, Server Actions work fine as do other components. I believe this must be something associated with either the app id or something else I do not quite understand, this is where my issue is. In what manner should these be included in to the Application is not clear to me, yet…?
Getting somewhere, if I rename the app id to the layout page app id it seems to work, so why are the content pages not inherently adopting this app id, and instead using the page/route name? Possible bug, or by design? Are there any issues with me replacing the app id with that of the layout page app id? Is there a reason the app id in the content pages has to be the same as the route/page name?
To try understand what you are trying to do, rather send your code and I will try tell you how to move it, sorry I am on my phone right now so can not get my code for a few hours still, but if you show me what you got I can try guide you, or tell you if what you are attempting is going to work or not.
Thanks again @ben, yes am aware of this as mentioned above (and from using the Components many times in other Projects), when I renamed the app id's all was fine. What I did not know was would it be OK to rename the Content Pages in Node from their adopted page/route names. In the end I just thought 'sod it' and tried, no adverse issues resulted. Then submitted a bug report, in hindsight should probably have been a feature request, to default the Content Page app id's to that of the Layout Page, and all resolved. As I said Node and Template page newbie here so catching up on a lot right now. All working as it should be.
Sorry can not see the link on my 200mbps fibre, will pull out my 14.4kbps US Robotics dial up modem, haha.
Just kidding, but damn you have been coding a while, haven't you.