-
I have 3 template forms in my app. I fiddled with the priority level of each one till my app worked, but I don't really understand what is happening. The signin forms belong to a template called 'Static'
The main app has a template called 'Router'
I have another template form that is used for redirects when the user is not assigned a tenant (multi-tenant app). Note that the staticwide template just has one route form with a path=''.
So my startup module has two redirects:
My second redirect, in particular, returns an error "staticwide does not exist" or something to that effect, when my StaticWide priority is set to 10 or below. Why doesn't the redirect cycle through all the templates to find the right one? Seems like there's some rule I'm missing. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Can anyone shed some light on how priorities work in the templates? Is this a bug or intended behavior? |
Beta Was this translation helpful? Give feedback.
-
I have created a simple app to demonstrate this issue about template priorities (no redirects this time): https://anvil.works/build#clone:EZ2VLNORHVNZXYY6=2UUZEMGIAMEF4HFAOZKG7FRG This app is quite simple: 3 templates and one route form that is shared between the 3. First one, Template1, is the default template with an empty path. The other two are given paths t2 and t3. When I try to navigate to t2 and t3, their priorities must be higher than the priority of the default template. Or else they will not be found. Their priorities relative to each other (t2 and t3) doesn't seem to matter, only their relation to the priority of the default template. Based on this, I have been able to deduce that templates with a non-empty path need to have a higher priority than templates with empty paths (default template), or else the routing module won't be able to find that template when navigated to. Starting to feel like this is a bug? @s-cork |
Beta Was this translation helpful? Give feedback.
-
Have you tried the redirects on the latest version of anvil extras? Your In general you should do priorities from most specific to least specific. We could probably make the And we could improve the priority code, so that if a valid template is found, but there is no matching route, we see if there were other valid templates. |
Beta Was this translation helpful? Give feedback.
-
That certainly helps clarify things. Thanks Stu. |
Beta Was this translation helpful? Give feedback.
Have you tried the redirects on the latest version of anvil extras?
If not can you try that and see if the redirect issue is fixed.
If you have, can you create a clone to show the issue with redirects.
Your
""
path should always have the lowest priority.templates are quite naive and just see if the url hash starts with the path you've given it
So the
""
is always a valid template.In general you should do priorities from most specific to least specific.
And redirects probably want a higher priority than templates.
We could probably make the
""
template have -1 priority by default.That'd probably make most apps not need to think about priorities
And we could improve the priority code, so…