I have a main template and some other templates that I use on separate web pages to display content. The main template holds the navigation.
How would I add a link to a secondary template that would do the same thing as the links on the main navigation template? In other words, if I wanted to duplicate a main menu link within a secondary template. Can I refer to the click function on the main template somehow?
I’m trying to call the function below (in Main template) from a secondary template.
def advise_link_click(self, **event_args):
"""This method is called when the ADVISE link is clicked"""
self.content_panel.clear()
self.content_panel.add_component(Advise(), full_width_row=False)
I tried the following with no luck. Not understanding how to call functions in Main from other templates:
def link_1_click(self, **event_args):
"""This method is called when the link is clicked"""
self.parent.advise_link_click()
The issue was that I was trying to cause a button click that is located in an added component (to Main), to trigger the function in Main that would remove the component and add another. Main acts as the header in the webpage and there are several components that I use to fill in the content on different pages.
On a related note, Is there a good way to add a link to a form that would scroll the page down (basically, to an anchor that is somewhere down the page)?
For what it’s worth, if you’re using that manner of navigation, you might want to do a forum search on Anvil Extras routing. It automates that navigation, and gives each page in your app a distinct URL that users can bookmark.
From the docs: Anvil Docs | Basic Components search for scroll on that page, there’s a section that shows how to scroll so a particular component is visible.