Internal Bubble Page re-direct

So… this is really hacky - but it works !

What we have is “slug” defined on a thing.

For the moment the slug must be 8 characters long.

So we have the following URL…

https://buildingonbubble.com/version-test/block/testslug

On PageLoad we check to see if Bubble has loaded a thing … if it has we are fine.

Note that you can’t check to see if the Page Thing is empty, you need to check that it has a field that you know should be there.

Now …we also check that if bubble hasn’t loaded a thing, that the last 8 characters of the URL exist on the database against the slug.

If they do exist, then we re-navigate to the page with the matching thing.

What we want to avoid doing is looping bubble on the page loads, as then bad things happen. Hence we must check that the slug exists or we will just go round in a loop.

Also… you can’t debug this, as you then can’t get to the slug name you just get the debug bit.

I actually don’t think we are too far off a less hacky solution, we are just transferring the responsibility of setting the page thing from Bubble to the Programmer. If we could find a way to get the final part of the URL back as an :extract then it would be a lot tidier.

1 Like

Actually…there is another way to do this and it doesn’t need the messing about with the URL.

What appears to happen is that the “unique id” of a page with a thing passed to it in a “pretty” format is preserved in the unique id.

So…

Here is a page that takes the data type “Word”. Word Up.

The Page is “slugtest” and we are passing “Shorterword” in as a parameter.

Pass in whatever you like after the page name, and it appears in the “unique id” as is.

Then just look that Unique Id up on something and you have your pretty/semantic/permalink.

2 Likes

@NigelG So we at last have a moment to try and play with this.

We’re trying to understand the Slug concept, but can’t find out how to see what you have in the first image you posted in this thread. To be honest, we’re not even sure if we still need that as you said later [quote=“NigelG, post:11, topic:3343”]
another way to do this and it doesn’t need the messing about with the URL.
[/quote]

Could you point us in the right direction? Thanks

Can you make this app public so we can see how you did it?

Thanks!

Brilliant!

Here we go.

Currently playing with the Contentful API and noticed they have slugs too. Am not making this stuff up you know :slight_smile:

@Nigel we’re going to push on Monday a fix to a bug that your method was relying on. So you should change the system in one way (it’s quick).

Instead of getting the unique ID from the page’s thing (which doesn’t exist, that’s the bug: you shouldn’t have it…), use ‘Get data from URL’ and pick ‘Path’. That’ll do exactly the same, and it’s cleaner.

3 Likes

Thanks, a proper solution :slight_smile:

2 Likes

Im i bit lost here, i don’t know if this is the right thread but im going to try it…

In my service, users will signup and they have a “username” field on the Users data type. Is it posible to automatically assign that username as their unique url?

For example if i signup and entered “charlie” as my username, my profile link will be domainname.com/charlie

How can i achieve this?

You probably can’t do …

domainname.com/charlie

But you can certainly do …

domainname.com/users/charlie

In which case the page name is users, and on that page you will use “get path” to find charlie and search the database for that user and display their stuff.

1 Like

I will try this! Thank you!

Hello @NigelG,

I’m trying to implement this solution but I don’t understand, I’m confused:

for example, I don’t understand which parameter should I send of my item, then how the “get from path” works to get back the item in the page (no documentation), then I don’t understand how this should shrink the url…

could you please give me a slower walk-through?

I would really appreciate that
Thanks!

Actually I think I’m starting to succeed… but there is one inconvenient I found in this method:

I can call the datas I want, in a group on the page, but I cannot tell “the page” to be based on that data…

this is a big restriction to determine accurate title and description for SEO, as this two can be referred only to “current page item” and “current user”

So on page load, when you read in the parameter, you can then store the thing on the User. So you can use it in the OG tags.

Ah ok, you mean saving the data on the user… but this way I waste one workflow per page load…Any idea on how to avoid it?

You could set a page’s content type to be a thing. Then see if you can extract the parameter, then do a navigation to the same page with the page thing. Although that will go from the www.yoursite/yourpage/thething simpler URL to one with the UID on the end.

mmm… actually I’m trying to make the url short for SEO purposes… adding redirection and finding me anyway in the page with ID, or not being able to set the SEO tags is a dog biting his tail… Maybe it is worth it to ask for the feature to be able to set SEO description and SEO title more dynamically, as we can do with page title (with a search for example…)?

2 Likes

Where exactly do I add the “get path” in order to get the /user/charlie instead of the crazy unique ID?

Down at the bottom of the list of options …