Dynamic creation of web items
We have now seen quite a few recipes on how to create web items and place them at different places in the UI. But in all the cases, we knew what links we needed. How about creating these links on the fly?
In this recipe, we will see how to create web items dynamically.
Getting ready
Create a new web item, Favourites, in the system top navigation bar, as discussed in the previous recipe.
How to do it...
Let us assume we want to create some links in the system top navigation bar. We have seen the same thing in the previous recipe, but that works only when we know the links in advance. Let us consider a new scenario where the user sees different sets of links when he/she is logged in and not logged in! Here the links change based on the user's status and hence need to be created dynamically.
The following is a step-by-step process to do the same:
Create a Favourites web section in the system top navigation bar.
<web-item key="favourites-menu" name="Favourites Menu"...