Template is a modal but need to be under new url route (for linking to it from other sites)

Hi,

I have created a template will open in a modal but I want that when you go to the modal it will show a url so I can link to it from other sites and the users will be taken directly to the page and the modal, any idea on how to do it with flow-router?

Thanks

You can detect the url then show modal based on that

Not sure I understand, can you provide an example?

I’m on mobile and don’t have enough space to code but let’s say you have the following:

  1. Router
  2. Template being rendered

The router will pay attention to a URL i.e “/posts/1/?showModal=true”

Then whatever template you tell your router to render for that URL (let’s say postsShow) it will check for the query param and then trigger the function to call it.

I.e:

postsShow.onCreated(function() {
if (FlowRouter.getQueryParams('showModal') {
  Modal.show('something');
});

This is very rough code, sorry, but it’s logically sound - we do this in a few places. Check out flowrouter for actual documentation on query params. I may have spelled it wrong.

1 Like

@dfischer Can you please expand on your answer? I’ve been trying to get this working in the last 2 weeks but still couldn’t get it right.
thanks