Forum Academy Marketplace Showcase Pricing Features

Can I assign a field value by default to a URL path (Should dynamically change for users)

So, i’m trying to building a SaaS app, where customers of a restaurant can order food from the table.

Now, I have a restaurant ID for each restaurant that signs up. Can I create a URL with the restaurant ID in it? I want to make sure that when people go to this URL which has the restaurant ID in it, they see the menu only for that restaurant.

Right now I’m able to achieve this when the user (The restaurant) is signed in. I want to add the restaurant ID to the URL so that users can type in the URL (Or scan a QR code), and the page shows up for that particular restaurant.

If this is the wrong way to do it, any other way that works would we great as well! Appreciate the help.

Yes, you can use the unique ID or the slug.

If the page has ‘Restaurant’ as it’s content type then it will automatically load the specific restaurant for the page based on the URL path (either the unique ID or the slug).

If it doesn’t, then you’ll need to use Get Data From URL on page load and match the database item to the URL path.

The first option is much simpler and generally the recommended approach.

Thank you much. Appreciate the help. So, right now, the page has “Orders” as its content type, which has the unique restaurant ID as one of the fields. How do I add this to the URL though? I need to read up a little more on slug maybe? Not sure how this works?

Coz what I want to happen is, this order URL should by default have the restaurant ID in it. (I’m not sure of how to do this). So, just going to this URL should show me this restaurant’s menu etc.

The URL Path can only refer to the content type of the page (in your case orders), so if you want to include the Restaurant in the URL you’ll need to add it as a URL query parameter then access it from there.

But there’s no need to do that if your order datatype refers to the Restaurant - so I’m not sure why you need to do that?

Without knowing more about your app or how it works I can’t really give any specific guidance here - but if you just need to access the data from the restaurant that’s connected to the page’s Order then that should be simple enough to do.

Perhaps share some screenshots and/or preview or editor links to give some more context as to what you’re trying to do, and where you’re having trouble.

I think i get it. The URL query parameter should help. (Now that i think of it. Haven’t used it much, so didn’t think of it. Kind of a noob here lol). Gonna try this out.

Need to pass it via the URL, coz i need to access one particular restaurant via one URL, out of the 100s of restaurants there would be in the database.

Appreciate the help. Gonna try the query parameter out.

Need to pass it via the URL, coz i need to access one particular restaurant via one URL, out of the 100s of restaurants there would be in the database.

But if there’s only 1 restaurant per Order (as I understood from your previous post) then you already have access to that.

Obviously, if each order has multiple Restaurants then you will need some other way to access the restaurant, so a URL parameter is ideal.

But if each order only has a ingle restaurant then there’s no need to over complicate it - just access the restaurant data directly from the order.

Ok, so the issue I’m having is, if I go the orders URL as a customer, to order something, I can’t see the food menu for that restaurant on the page, because, the page is set to show the food menu that matches the restaurant ID of the “current user”. (And since I’m a customer, I’m not logged in and it doesn’t show me anything).

I’m not sure of how to tackle the issue.

For this page, you would change the menu to load the “current page’s order’s restaurant”

1 Like

At some point I need to assign the restaurant ID to the order. (Order is something that is created anew, every time someone lands on the order page).

I’m trying to figure out how to assign this dynamically, based on which restaurant the customer is ordering at.

Wouldn’t it make more sense then to have the page content type as ‘Restaurant’?

Why does the page type need to be order, if a new order is being created on every page load?

I would just have the page type as Restaurant, with its own slug, then on page load create a new order with the current page’s Restaurant assigned to it (if that’s what you need to do).

I agree with most users that the page should probably be a “restaurant”, but… if you’re sending the user to the “order” page from a page that has the restaurant data, you can send it as a url parameter when you navigate to the new page. For links, this will be under the “send extra parameters” option. You’ll name the key for this parameter as “restaurant” or “r” and it’s value to the restaurants unique ID. Then you can get the restaurant ID using the “get url parameter” option in data sources or conditionals. I’m on my phone but can add screenshots later.

Wow, the slug thing worked. It sounded too complicated when you said it (I’ve never used slugs before). Tried it out, and it was simplest solution ever! Thanks much Adam Holmes. First time using slugs (Have always wondered how they worked). A new learning curve indeed for me! Appreciate it. This is going to work wonders for me.

Thank you gbenhanoch! Appreciate it. :slight_smile:

1 Like