How to detect when url has no parameters?

Hi everyone,

I’m wondering if there is a way to detect when the url has no parameters.
I would like to show an icon only when the url has no parameters, which means it’s the homepage.

Thanks!

1 Like

I guess this might work: this url: extract with regex count is 1 where the item to extract is ? (or does it have to be escaped like\??).

1 Like

Thanks for your reply!
It works, the problem is that it only detects changes in the url when the page is refreshed/loaded, not when I navigate using url parameters (to show/hide different repeating groups of my single page app).
I had tried a similar approach by using this url contains "?" and it does the same thing.
I guess I could try using a workflow to show/hide the icon when it detects a change in the url, however it seams a bit of a wastage in terms of efficiency?

EDIT: The workflow also doesn’t detect changes in the url unless the page is refreshed.

I’m probably missing out on something but you could probably just use get data from page url and have a condition to only show a group/rg if the parameter is not empty. Just hide it by default

Something like this:
image

1 Like

Thanks for your reply.

That’s what I do to navigate to different section of the app. The problem is that now I want to show one icon only when there are no parameters of any kind (which means that i’m currently browsing the homepage).

I can use a condition for that icon that gets from the url all the types of parameters that I’m using and only shows the icon when every parameter is empty, and that works. The problem is that the list is long and i need to add a new search every time i create a new parameters.
And I need to do this for any item that I only want to show on the home page.

So I was wondering if there is an easier approach to simply detect when the url has no parameters.

From what I’m seeing: get data from page URL detects any change instantly. While this url contains need the page to be refreshed in order to detect any change.

Another workaround to detect if current user is in the home page is having the condition current page name is index

image

Unfortunately, for whatever reason, this condition only works on Reusable Elements. I wonder why this condition isn’t available for elements that are not inside an RE…

IMO, the simplest workaround would be to put your icon inside an RE and use this condition

the problem is that I’m building a single page app, so index is the only page :slight_smile:

Oh, I didn’t know! Learned something today.

To get around that, you could use the when page is loaded trigger with the condition this url: extract.... Then you can set a state…


FYI: I’ve put together a SPA guide a while back using show/hide everything with get data from page URL. https://www.youtube.com/watch?v=QdzGIdmhxs8&list=PLGIPNPvC76kfpYQzUhyBqRQw7XH_VUqBI

Yes, it’s the old engine. Yes, I’ve got a plan to upgrade/update this tutorial… mañana.

1 Like

Thanks Rico,
I just tried this approach (full of hope ahah) but it didn’t work :slight_smile:
this url still requires the page to be refreshed and it doesn’t work when navigating on a single page app.

But I seem to have found a solution that works with this workflow:

on page load, I set a state for the page index (state name “url”, type “text”, dynamic content “this url”).
Changes in “this url” get detected even if the page is not refreshed, as when navigating in my single page app.
Then I can show/hide anything according to that state, as state changes gets detected instantly.

1 Like

Event: Do when condition is true
This url:split by (?):count > 0

maybe? idk.

1 Like

Changes to “this url” only get detected when the page is refreshed, so not suitable in my case (single page app). But I found a solution in my last reply :slight_smile:

1 Like

FYI Bubble’s go to page action happens instantly when you go to the same page.

I’m not sure if this applies to your case, but I found that the hidden benefit of using parameters (or paths) is that it becomes easy for users to share urls to specific parts of the app.

You mean on page load workflows happens also if you go to the same page?
In that case, yes, the workflow still runs. The problem is that if you go to the same page, the this url condition doesn’t get updated, if it has changed. I think it uses a cached version of it and only refreshes it when you refresh the page.

and I do use url parameters for navigation. What I meant is: with the current url stored in the custom state of the index page, I can show/hide the icon that I need to hide on the homepage only.

Hi there!
I had the same problem and solved it by simply adding a new parameter that would be always set when any other parameter is set and it remains the same value (e.g. search=active).
This way, I only had to use a conditional lookup for that parameter to determine if there were any other parameters as well.

This topic was automatically closed after 70 days. New replies are no longer allowed.