Forum Academy Marketplace Showcase Pricing Features

Quick question about "this url is"

I am trying to set a conditional for a reusable element to appear

I have the following paths:

website.com/new/sluggoeshere
website.com/edit/sluggoeshere

When the page is “edit” I want the reusable to appear, currently I am using a this url “contains” edit argument to trigger the reusable element, but this doesn’t seem very robust (for example if the slug contains the word edit it would also trigger, which is unlikely but could happen)

Does anyone know a more robust way to do this? It seems like there should be a better way?

Thanks

If ‘new’ and ‘edit’ are different pages why do you need conditionals for this? Just show the reusable on the edit page and not on the new page.

@adamhholmes Good question; because the new and edit pages contain large overlap in design, I am making use of a large number of reusable elements, and actually the reusable element I am trying to conditionally display is nested inside another reusable element which is common to both pages.

Ideally I’d like to use the URL; and I’ve wondered about this a few times on different projects, but always just found another way… rather than asking the community.

For example another method I can use is setting a state on the reusable element that is set differently on the edit page and the new page, and allows the reusable to “know” where it is.

I just feel programmatically, there might be something that can be done at the URL level (e.g. “when page is edit this element is visible”) and I’d like to explore this and hopefully add another tool to my belt!

Best

Instead of „this url“ you can use „get data from url“.

Use „path:first element is …“

This will only check the first part of the path.

1 Like

Exactly what I was looking for! thanks very much!

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