Im new to Bubble so sorry if I am missing anything but in order to make a user profile page it seems like you need to make a page as a template of sorts and then forward the users data to that page. That then makes the URL WebsiteName/ProfilePage/Username. There doesn’t seem to be any way to forward the data to index or to remove the ProfilePage part from the URL. Is there any workarounds or am I best just doing something like naming the page “p” to keep it short?
It seems what you are referencing is to have it to where users can visit other users profile pages? Like if user1 was logged in and went to website/profilepage/user2 then they would see that user’s info? The way I think to acheive this best would be to set up a generic profile page that gets its data source for the user from the url. Then when a logged in user clicks on another users image to go to their page you can use the action “Go to page” then select the generic profile page and check the box to pass parameters and pass the user whose image was clicked unique identifier as a parameter.
Yea I’ve got that part figured out but it makes it so that the name of the generic page is added to the URL.
Is there any way to do?
Look up window.history.pushState. You can make the url say anything you want after you grab the url parameter so the user sees something more legible.
I found your post here about that How to restart current page parameters? (Keys)
and it might be what I am looking for. However it seems like it will adjust a page’s URL not change it. So if someone goes to website.com/profile/username I could have it remove the profile part and just show website.com/username
but if someone just goes directly to website.com/username via a link or typing it in the address bar, would it still work?
Oh I see. No in that case it would not work.
No, unfortunately. It’s just the way Bubble works. The first path parameter MUST be a Bubble page.
I think that’s your only option.
Tons of posts on the forum about this, BTW. Just search for “url router” and/or “sudsy page”.
@ericdf94 You can create the profile ‘page’ on your index page - just have conditions for when to show the group based on what it finds in the URL and also pull that data to tell the elements what record to show.
Use ‘get data from URL’ and then use path parameters
I might be misunderstanding, but in my experience, Bubble interprets the first path param as a Bubble page and attempts to load it, which will just lead to a 404. Maybe something has changed with the platform though. Do you have a working example?
Oh it could very well do that - I haven’t tried it on the first path
I believe this can be done in pure Bubble - no JS needed. I often pass data this way from reusable elements (even if they’re nested within a repeating group) in lieu of using custom states.
Yes, you can have www.yoursite.com/username.
I’ve done this a few times for my projects. It’s completely doable just with Bubble. I’m going home right now and when I get there I’ll post the solution.
Wow! Looking forward to learning how.
Hopefully, it doesn’t involve a redirect, though. That’s been mentioned on the forums and would not a workable solution for my needs.
First of all, it is important (and obvious) that you will need a “username” field in your user’s database in order to be able to relate the user according to their “username”. So when you
Search for a user where username = crazy_orange, you will be able to get all his information…
That’s been said, let’s pick as an example the URL “www.mysite.com/crazy_orange”
As @sudsy already said, bubble will interpret the “crazy_orange” path as a page and will try to load it. Bubble will fail and automatically redirect the user to the 404 page.
And here is the trick.
Note that when the 404 page loads, the URL will still be “www.mysite.com/crazy_orange”
So everything you have to do is to create the profile page INSIDE the 404 page.
Ok, but how can I access the parameter “crazy_orange” in order to be able to pull information from this user?
Easy. You ALREADY have it in your URL (www.mysite.com/crazy_orange). You just have to use the action “Find and Replace” to get rid of your Website home URL, leaving just the “crazy_orange”. You can do something like this:
Boom . The result of this operation will be “crazy_orange”. Now you can use it to
Search for User where username = crazy_orange.
If the :count of this Search is zero, then you don’t have this username in your database (and also don’t have this page, remember that you are in the 404 page). So, in this case, just show an alert or some generic text informing that the user is lost and bla bla bla…
If the :count of this Search is > 0, then you know that the user exists. In this case, show the profile.
Hope it help you guys!
Thanks for taking the time to share, @rpetribu. Yeah, that’s been mentioned on the forums before, and unfortunately, it kills SEO.
If one’s sole concern is strictly what the visitor sees in the address bar, then I guess it might be an option, but there will also be a performance hit with the redirection.
Yeah, to be very clear about this (what @sudsy is saying), such pages would not be indexable, and would be crappy in other related ways (like, what’s the unfurling image going to be when shared?).
It’s much better to use the same lookup technique on a “real” page. A lot of discussion about this in the following old thread:
Yes yes… you are right! But this is the simplest way to do it. You barely feel the redirect! I use it and it really works well!
But yes… it will kill the SEO, but this is generally a sub-page (of a user of the app). It’s not a big deal.