I transformed a dynamic page to a regular page and then accidently deleted the dynamic dataset but replaced it with an ordinary dataset. This was mostly for a comments section but when I now try to add a comment it does not show up so I wonder if I would need the dynamic dataset also for the regular page? With other words; are dynamic datasets only meant for dynamic pages?
are dynamic datasets only meant for dynamic pages?
YES .
Dynamic-Datasets would not exist, if there wouldn’t be any difference between ordinary ones and dynamic ones.
Ordinary ones are able to show you the whole data of your DATABASE.
Dynamic ones will give you back always just ONE-ITEM, only.
Also you will recognize some outgreyed DATABSE-FIELDS inside of your database, after you have turned your normal page into a dynamic one.
This outgreyed fields will represent your dynamic pages (working like a link to one of the dynamic pages (dynamic items) → conclusion dynamic dataset.
Getting the current item on a dynamic page will always gives you back as result the current item on each of selected dynamic pages.
Getting current item on an ordinary page without getting a specific ID of an item, it will always return you one and the same item (as i can remember → always the first one, or was it always the last one?) test it.
Before the ordinary dataset can give you back a real result, you will have to tell which one of the items you want to get exactly…
Example:
$w("#myDataset").getItems(3, 2)
.then( (result) => {
let items = result.items;
let totalCount = result.totalCount;
let offset = result.offset;
} )
.catch( (err) => {
let errMsg = err.message;
let errCode = err.code;
} );
Or you have to use an elements like …
- repeater
- table
- …or any other element to determine which item is the current one at the moment, only then you are able to use → “getCurrentItem()” on an ordinary dataset.
So you recognize now the difference?
Question!
What does represent a → loaded dynamic-page <— regarding your database?
Thank you very much Ninja for the clear and detailed answer. So with other words, I can delete the dynamic dataset after I have made a dynamic page to a regular page?
Yes, if the dynamic DATASET do not turn back automaticaly to normal one, you can either reconnect it to normal page, or delete it and add a new normal one and connect to the normal page.
Normal page = normal dataset
Dynamic page = dynamic dataset
And think one more time about…
What does mean -->dynamic ← ecactly?
Yes you have made me understand that very good now
I also write this question here because I have not got any answer on my latest topic about members profile- and account pages:
What is the fault in this code because when I click on button1 I am relocated but it can´t find anything. Same fault with button 2 to get to the account page. Very confusing because I have copied the exact URL for the both pages (not a specific members profile and account URL but to the two dynamic pages.
When I try without code and through a direct database-connection I am relocated to the wrong members profile page (same with account).
import { currentMember } from ‘wix-members’ ;
import wixLocation from ‘wix-location’ ;
import wixUsers from ‘wix-users’ ;
export function myGetCurrentMemberFunction ( options ) {
return currentMember . getMember ( options ).
then (( member ) => { const memberId = member . _id ;
return member ;}).
catch (( error ) => {
console . error ( error );
})
}
export function button1_click ( event ) { wixLocation . to ( /members/profile/{ID}
);
}
export function button2_onclick ( event ) { wixLocation . to ( /members/account/{ID}
);
}
Seems like you mixing front-end and backend.
I see an EXPORT-FUNCTION in your frontend code, right?
export function myGetCurrentMemberFunction(options){......}
Regarding your API-IMPORTS, it seems like you are working on FRONTEND…
import { currentMember } from 'wix-members';
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
But you do not import your exported backendfunction on your FRONTEND, as i can see…
import {myGetCurrentMemberFunction} from 'backend/xxxxxx.jsw}
BACKEND is not FRONTEND and FRONTEND is not BACKEND.
And why you do not use - - → CONSOLE-LOGs ???
If you would start to use them, you surely would be able to debug your code on your own.
Okay, thanks… but what if I just wanna work with frontend?
What should I then rename export function " myGetCurrentMemberFunction ( options )" to?
You should first make clear what is FRONTEND, what is BACKEND and what is the difference between this 2.
Not every API-CODE provided by wix/velo will work on frontend, also some code-line will not work on backend, which work on frontend.
https://www.wix.com/velo/reference/wix-members-backend/currentmember/getmember
I assume this is your - - → getCurrentMemberFunction() ← - which you were using in your code.
But this function is (like already mentioned before) is just for the BACKEND, it won’t work on frontend.
You will have either to use it (but on BACKEND), or to look for a frontend-supported API which would work on frontend, like here…
https://www.wix.com/velo/reference/wix-members/currentmember/getmember
I have tried the latter one but the (options) text was marked red because it could not find any “options” in the code. It is confusing for me that a frontend version also want some kind of .js backend page to work? And the problem with backend versions is that you either need to manually write in every new member there or you have to make that automated but I don´t have a clue of how I can do that. With other words, after a registration the new members concact information shall automaticaly be sent to the custom backend-page, so how can I make that happend?