Node newbie question (content/partials/layouts)?

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?

Have a look at https://docsdev.wappler.io/guides/creating-a-shopping-cart-with-the-data-store-component?id=checkout-page-overview

where you will see

In order to be able to use the Data Store data on another page, let’s say a checkout page there are two requirements you need to follow:

  1. The App ID must be the same as on the page where you defined the Data Store:
  2. The Data Store component ID must be the same as the one used for the shopping cart:

How do you bind data to the partial if you can’t see it in the picker?

Have to do it in code view, but it easier to just build your stuff inside the content page and then move it to a partial afterwards.

I’ve tried using the template variables to pass data to the partial but it was a headache so I just moved everything inside the content page.

Can you share an image showing how you do that? The data binding in code view…

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.

Again thanks for your input much appreciated.

1 Like

Am having flashbacks of building Frame based pages!

:smiley:

For those that don’t remember Frame layouts:
https://www.w3.org/TR/html4/present/frames.html

1 Like

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.

1 Like

Started creating basic pages using a text editor (in FreeBSD) around the HTML 2 - 3 update. Remember my HTML Reference book was the size of the Bible! :slight_smile:

Edit, actually before that used to create menu driven systems for VAX clients on DEC Mates hahaha… Yay green text!

1 Like

I only retired my text editor about 3 months after Wappler was born. Used to open Dreamweaver, add a DMXzone component on a blank project, copy all the files and code into my site, open my text editor and add all the new code rather.
90% of my day was in BBEdit and Espresso, and the rest was Dreamweaver.

I tried only using Dreamweaver, but I was doing smaller sites back then by the hundreds, and I would open them once a year for a price update, and Dreamweaver/DMXZone would update everything, code would go flying, and I was too scared to break the site, rather just opened trusty old BBEdit and make the alteration from 100 Dollars to 110 Dollars.

1 Like

Was privileged to work with a guy that could reverse engineer just about anything back then, would pass us reams of printouts, tens of metres in length, about 10" deep. Go through with a highlighter marking off blocks of code and then trying to manipulate it to work within my own creations, a kind of manual Stack Overflow of sorts hahaha… Haven’t moved on much since those days!

:smiley:

1 Like

As you know @Dave, I just started playing with Local Storage, however I could not easily change my app id to be the same over some of my pages, so I decided to add the base local storage as the first element of the layout pages body like this.

    <script src="dmxAppConnect/dmxStateManagement/dmxStateManagement.js" defer=""></script>
</head>

<body is="dmx-app" id="main">
    <div is="dmx-view" id="content">
        <dmx-local-manager id="pim_local_storage_manager"></dmx-local-manager>

Then on whatever server actions I need to use it on I just add it like this, the below is from a partial, so linked to a Layout -> Content -> Partial

<dmx-serverconnect id="scimagelist" url="api/main-list/original-image-list" cache="content.pim_local_storage_manager" ttl="3600"></dmx-serverconnect>

This has a different App ID but still works when i look at my inspector -> Network tab as well as the Inspector -> loac starage area. Am I not seeing something?

Mate I’m so confused with Layouts and Local Storage. If we don’t have matching app id’s we can’t clear the cache on content pages. Try and see if you can clear it, simple Dynamic Action on a button etc? Obviously important it clears especially if you make changes otherwise they will not be displayed until the cache TTL expires. Only way I could clear it was the app id route.

1 Like

Just tested with a remove all, and that works too.

So i have a Layout page called main.ejs id="main"
2 content pages

  • first called index.ejs id="index" which has a login form on it on success it redirects to second content page
  • second content page called dashboard.ejs id="dashboard"

100 partials mainly connected to dashbard.ejs, the one i am testing with is a partial called image-list.ejs id="image-list"

I can not use the data pickers to get select the base local storage component, but I can manually insert the code, and it works.
Same for the local storage removal, cant select from data pickers but can manually enter and that works too.

Code for removing local storage data is.

<!-- Works with or without content. -->
<button class="btn btn-danger" dmx-on:click="content.pim_local_storage_manager.removeAll()">Remove Storage</button>
1 Like

If you have the same app ids the spinning cog is replaced with the select options. This is one of the issues I have covered. Can do it manually as you have pointed out, but really this should not be the case.

1 Like

Did incorporating the Local Storage make a difference to your page performance @psweb?

It did in some ways, but I am going to certainly have to fiddle around more, as currently on one of the largest queries it actually made it worse, but I also think thats browser render time, but certainly I can see I will have massive benefits in using this. You explanation on how to use it was perfect by the way, thanks buddy.

1 Like

You could also make use of the Redis caching on the server side within your action Paul, that may help? Only for Docker/Node deployments though…

Can employ it by following this guide:

1 Like

Thanks Dave, will take a look at that, never tried it before either, haha.

I think my biggest confusion is this.

The page loads, 50 images are displayed with all their set data from the database, 1 image and its data per row.

Now there is functionality per image displayed, such as assigning a 1 - 5 star rating per image.
On Click of the star the user selects, it instantly writes the value to the database, for the relative image id.
Then after it writes that it now needs to re-query the 50 images in the list, and display the adjusted data.

So to set 5 star ratings to 50 images it re-queries the image list database 50 times.

What I may need to do is wrap all the controls for each image in a form and have the user set what they want and then click submit so it can do star rating and image tags, and photographer assignments, etc. all in one go, and only then after update re-query the image list to populate the new details.

Unless there is another way I can keep this sort of ajax style click once and its updated without having to reload the entire list after each click to populate the new data.