Hash Routing with Templates - Fail to make it work with some variation from the original #454
-
Hi, Starts in a landing page (that currently just has a button to initiate) Once you log into the application, you should be taken a different page (Template) that will have the menu options according to the area defined for your user, and the Forms corresponding to that options. The area in wich you work is an attribute of the user (unidad) and is taken from the users table. (Marketing is the only one implemented so far) 3 Once you logout you should return to the landing page For achieving this I: Defined several Templates for Hash Routing to different groups of Forms mimicking the Hash routing with templates example. Mainly because the behavior I intend to have is very similar although it has some differences. Each Template corresponds to a different area, and it has several associated Forms, and a different menu. Once you login you should be directed to the corresponding Template that will call the Home Form for that Template (and not the Home of any other Template ), then generate and display the right menu for the user, that in turn will allow navigation to the rest of the Forms for that area. The menu is generated dinamically in each Template using Navigation module. Basically the problems starts when I log in and try to navigate to the Marketing area (the only one I have defined so far, and the one the user belongs to). It then starts behaving oddly and unstable. I’ve looked at the logs for the routing module when executing, and they show a behavior I can’t trace/understand. I’ve read the hash routing documentation but I can’t make a match for those error messages. I think that the mechanism works well, and it’s me that have been unable to put the pieces in the right place and order. Here is the application. In case you want to test the behavior, the user for loggin in is [[email protected]] and the pass is uSuario-1. This user belongs to the Marketing area, and so after login in should redirect to the Marketing menu, and be able to select the items from this menu and opens those Forms. https://anvil.works/build#clone:MEZWXQDDZIV5RRLD=JUZZCTBVGTXKM6NEKAMHPSRO|C6ZZPAPN4YYF5NVJ= Below is the routing log that shows how once you are in the Marketing menu and click on a link (RedesSociales) it navigates back to the Public Template (I can't understand why), and throws an error because the /redesSociales path is not registered there, but in the Marketing Template. At this point I'm not able to map the code and the clicks with what the logs show.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
From what I can see you've misunderstood the path part of the Template argument @routing.template(path='Marketing')
class RouterMarketing(RouterMarketingTemplate): The above code says - my But the menu you build for the assuming that's what you want the URLs to look like then fixing your built menu should fix the navigation If you want different URLs you'll need to think about things a little differently. |
Beta Was this translation helpful? Give feedback.
From what I can see you've misunderstood the path part of the Template argument
The above code says - my
RouterMarketing
template has all paths starting withMarketing
But the menu you build for the
RouterMarketing
form sets the hashes to (e.g.)"/mercados"
, which should be"Marketing/mercados"
.assuming that's what you want the URLs to look like then fixing your built menu should fix the navigation
If you want different URLs you'll need to think about things a little differently.
If that's the case let me know and we can look at this.