How to set Page HTML Header for Conditionals

I am using structured data in my page HTML Header

Screen Shot 2020-07-12 at 5.01.19 PM

The problem is that on the conditionals tab of the page, it is not possible to set the page HTML Header to another value

Screen Shot 2020-07-12 at 5.02.37 PM

I’ve tried to use an HTML element to set the ‘head’ of the page

But it doesn’t work. It also doesn’t work if I remove the HTML opening and closing tags.

My hope was that using an HTML element to set my Page HTML Head would allow me to use the conditional settings on the HTML element to set my Page HTML Head conditionally.

The main reason for wanting this ability to set it conditionally is to have two different scripts run dependent on whether the event is online or in a physical location.

Is there a way to set an HTML element to have the page head HTML and be recognized? I feel like it should, but assume that I am just doing something wrong with the code.

1 Like

Hello @boston85719

Would this be a solution for you?

1 Like

Okay, so I have a data field on my data type which is an option.

It is a data field labeled as ‘Venue Type’ which is an option from which the option set has “online”, “indoor”, “outdoor”.

So, from your suggestion, I believe what I would do is set up

“do search for event (finding the event listing on page): first itemVenueTypeOptionDisplay is not online: formatted as text”

This should give me the ability to recognize an ‘online’ event and if the formatting is yes, I would put the structured data for an online event in Yes, and if it is not an ‘online’ event, I could in the no formatting put the structured data for a physical location event.

I will give it a try, but seems like a workable solution as I only need two types of structured data.

Awesome, this works. Thank you for that.

1 Like

Thank you, too.

Also, not only when there are two data types, you can probably replicate these options using find & replace. (I haven’t tested it is just an idea.)

I want to set up different header for test environment and production.

How to do that? In the conditional options, I don’t see the “Isn’t live version” option.

Like has been told here in the earlier solution, I can probably have one table in my database which would indicate whether it is production or test. But that sounds more like a hack/workaround. Is that the official way of doing it?

There is no official way of doing anything in bubble really as there are almost always multiple ways of arriving at the same destination.

What conditionals are you looking at? As noted before, as the main reason for this thread

If you plan to change the header HTML on the page you should make some attempt to figure a way to use the solution on this thread…

There are so many things that we have to do in bubble that seem like a hack or workaround, but in the end if that is what is needed to get the functionality, then that might be what you should do.

I only have one thought of how to not use the DB for this

I have not tested and do not know if it would work, but it is my only thought on how to avoid the use of the DB

I tried the solution of creating an entry in db that indicates whether it is live or test version. And it is working fine. So, thanks @eren for that.

@boston85719, thanks for the suggestion on using url to figure out whether it is test/live. It is probably better to use db solution though I think, as it doesn’t really rely on “version-test” string. Bubble could change this string tomorrow to something else, or our some URL itself for some reason may have “version-test” folder in it (highly unlikely though).

Looks like I have upset you. Not sure why though.

Yes, there are many ways of doing things in Bubble, but unlike what you said there are official ways of doing some things. e.g. one can figure out whether it is live or not using your method or db method or just using “Isn’t live version” in conditionals. Now Bubble has offered this as a condition officially, isn’t it? Naturally that is the best way to determine live/test if it is available in the context. We can use many workarounds in many other situations too. e.g. if we had to find out whether user is logged in or not, we could use some funky db workaround for that. But why do that when Bubble gives a direct solution to that?

If we don’t try to find out what is the right way of doing things, we would probably not learn. Hasn’t it happened to you ever before that you used to do some things in some way and later found out even better (or more right) way of doing that thing and then onwards preferred using that only?

Do you suggest that one should only focus on finding some solution for things without bothering for what is the right way of doing it?

No, you didn’t. If you had I would not have replied and offered an alternative solution to your issue.

If you want to use the official “isn’t live version” conditional you can’t because the header html can not be changed conditionally. It is because of this that the solution you have implemented is not considered as an official way of achieving your goal since bubble has not allowed for it officially, but instead a workaround as you previously described it.

This speaks directly to my point in a roundabout way. As I said there are many ways of doing things, so learning about them is a great way to improve overall in bubble as you could at times utilize the same strategies for other use cases, so relying solely on what might be described as ‘the right way’ should not be thought of as the only way.

It is important to understand that so as you progress you can ‘think outside of the box’ to come up with creative ways of doing things, as trial and error is a great way to learn more about bubble.

I think you got a little too hung up on this idea of “official” “right way” of doing things and misinterpreted my first reply to you which was not meant to insult you in anyway, but to help you progress and to keep an open to the idea that there are almost always multiple ways of doing things, and even the bubble tutorials on how to build clones do not always prescribe their methods as “official”…

the only real official ways of doing things are found in the manual…most everything else is a workaround.

1 Like