How am I able to bind page so it works in editor and the published application?

I have a dynamic object which returns the page a button should be navigated too.

I see there is a context.pages object with a list of all the pages, including an id and path for each. I am trying to use the id for the editor which works and the path for the published app but it isn’t working.

How am I able to bind the page property dynamically?

image

I tried it with this code. Works in editor but not the published app.

var pageObjects = context.pages

var pages = Object.entries(pageObjects).map(x => x[1])

var page = pages.filter(x => x.path == function_url.replace('/en/',''))[0]

if(context.browser['environment'] == 'editor')
return page.id + '/'
else
return function_url + '/'

Using the page id in the published app doesn’t work ?

No, it doesn’t. Tried that

I also want system to navigate to specific page which is previously saved to a variable.
If I bind page [id] or page path or page itself, it doesn’t redirect even in editor, just doesn’t work.

what exactly from “page” should I save to var and then bind? what am I doing wrong?) thanks in advance.

@Anna.fae Yours won’t be working because you aren’t using the ID. You can see the current value isn’t just the id. You have concatenated the context.pages object.

1 Like

thank you a lot, fixed. now works in editor

@Alexis What do you suggest? How can I bind the page property and it work?