Hey, wonderful people. I have a question that I believe is pretty basic, but due to my limited knowledge of coding, I have spend over 12 hours. May be someone over here can help me.
I am trying to create a link on an item page, that would change based on one of the fields/columns in the attached database. For example, on the link below:
If someone clicks ‘sub-type’ I want them to be directed to @JoinDrSuri. One of the columns in my database is called “condition.” for the item ‘anxiety-1,’ the condition is Anxiety. Now, I want the link to follow the wixLocation.path for the initial part of the url (until prefix), then pull data from the relevant column in my database (in this example, condition column for anxiety-1), and then the static “sub-type.”
The part that I am struggling the most is pulling the relevant data from the database. Any suggestions?
You have two collections, with two dynamic pages. The first collection can have a reference to the second one.
If this is the case, as whenever there is a dynamic page, we also generate a field that is a link to the dynamic page, if the trip collections are linked class a reference fields, you can directly link from the first collection to the second collection item pages.
E.g.
Collection a has an item page
Collection b has an item page
Collection a has a reference field to collection b
So in the collection a item page, you can connect the b collection item page link fields as a button link.
Thank you for your reply. My situation is slightly differernt. I figured that I do not need to have two collections for two dynamic item pages. I simply have 2 columns in one collection/database, let’s say collection A. Column A lists, say the apparel types (jackets, pants, jeans). Column B has individual items jean-blue, jean-black.
Given how we set dynamic item pages in Wix, I have a single-item page mysite.com/collection/jeans that displays information as a single-item page (not as a category page). eg. This page talks about why jeans are comfortable. Likewise, mysite.com/collection/shirts will talk about shirts. These pages may or may not have a link to another single-item page in this collection mysite.com/collection/jeans/jean-blue.
I hope that helped with elaboration, and not too confusing. My understanding is that I am trying to create links in the menu that are part static and part dynamic. I am trying to get the url to do this - mysite.com/collection/{column A}/origin-stories.
I can use wixLocation to get the url path mysite.com/collection/ portion, and I was able to add the static piece ‘origin stories,’ where I struggle is getting {column A}. I need the code to read the current URL to identify /jeans or /shirt (and not /jean-blue or /shirt-blue) and copy that into the url, based on where the user is. Alternatively, if I add a column C in the collection, and can get the code to read column C for any given item page (say 'jeans/jean-blue), then that should work too. I will go type jeans into column c for jean-blue, jean-black, etc.
Hope that clarifies, and hope it is a quick-fix. I appreciate your time in trying to understand my situation.
Is the page mysite.com/collection/jeans/origin-stories a dynamic page, from the same collection? I am asking because you have a link Field in your collection that you can just use directly.
Yes Yoav, it is. In fact, my original plan was to simply have URl columns and connect buttons to the relevant columns for links. The main problem with that was that since I had to enter the URLs in https:// format in the collection/database, they would all open in a new window, which creates a very unpleasant end-user experience. If I ca get them to open in the same window, that would be great.
P.S.: I tried $w('MyElement).target=“_self” while having the button linked to a URL column in the collection, but sadly, it did not work.