# Create dynamically pages

**URL:** <https://community.plotly.com/t/create-dynamically-pages/50870>\
**Category:** Dash Python\
**Created:** [March 10, 2021, 5:49pm UTC](https://community.plotly.com/t/create-dynamically-pages/50870 "2021-03-10T17:49:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fifis](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@fifis](https://community.plotly.com/u/fifis)\
**Post date:** [March 10, 2021, 5:49pm UTC](https://community.plotly.com/t/create-dynamically-pages/50870/1 "2021-03-10T17:49:17Z")

</div>

Hello,

I am working on a multi-page app in which one page contains cards for all people in the database (every card contains a picture, name and position and a button), when the button is pressed it sends you to the page of the person where you can find plotly graphs.

I cannot find a way to update the link dynamically.  
What I have is app.py, index.py, folder pages and app1 and app2 there. app1 is the one with all people and their cards, while the second is a normal dash app with the graphs, where to change the graphs specifically to the person you have to give a variable called ‘value’ the name of the person.

Is there a way to modify this ‘value’ with the name of the person which button is called from app1. I have tried to pass global variable but since the name is created into a string inside a callback function, it is not updated globally, I tried to use callback to dropdown in app2 but that is not working either. I don’t know what to do anymore.

The code is for uni project and I am not sure if I can post it here.

Is there a pop-up window option that can show the graphs dashboard so I can put all the code inside one file instead of going to another page?

I am sorry if the description is not enough!

---

<div class="post-metadata">

**Author:** ![danpryjma](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@danpryjma](https://community.plotly.com/u/danpryjma)\
**Post date:** [March 11, 2021, 12:39pm UTC](https://community.plotly.com/t/create-dynamically-pages/50870/2 "2021-03-11T12:39:19Z")

</div>

You can use this example to look at details:  
[https://dash-gallery.plotly.host/dash-financial-report/](https://dash-gallery.plotly.host/dash-financial-report/)

> **[plotly/dash-sample-apps](https://github.com/plotly/dash-sample-apps/tree/master/apps/dash-financial-report)**
>
> master/apps/dash-financial-report

You can use a similar callback as below:

```python
# Update page
@app.callback(Output("page-content", "children"), [Input("url", "pathname")])
def display_page(pathname):
    return app2.create_layout(pathname)

```

Basically what you are looking into creating is a function in app2 that takes the person’s name as input and generates their page, app2.py would look like:

```python
def create_layout(username):
    # get data from DB
    df = pd.Dataframe.read_sql(sql code)
    
    return html.Div('''put your page details with the person's info here''')

```

Does that make sense?

Daniel

---

<div class="post-metadata">

**Author:** ![fifis](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@fifis](https://community.plotly.com/u/fifis)\
**Post date:** [March 13, 2021, 4:06pm UTC](https://community.plotly.com/t/create-dynamically-pages/50870/3 "2021-03-13T16:06:36Z")

</div>

Thank you so much for your response. It definitely makes sense and I changed my app accordingly. You have no idea how much you helped me!

I created the pages to contain app1 = layout(app) and app2= layout(app, name).

In app1 now I only create the cards and put them into the layout, however now I have no idea how to get the name of the button that has been triggered last.

Can this be done inside the app.py?  
this is the code inside the app.py

```
        Output("page-content","children"),
          [Input("url", "pathname")])

 def display_page(pathname):
      if pathname == '/apps/all_profiles':
           return all_profiles.layout(app)
     elif pathname == "/apps/profile":
          return profile.layout(app, name')
```

---

<div class="post-metadata">

**Author:** ![Eduardo](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/eduardo/32/13310_2.png) [@Eduardo](https://community.plotly.com/u/Eduardo)\
**Post date:** [March 13, 2021, 7:57pm UTC](https://community.plotly.com/t/create-dynamically-pages/50870/4 "2021-03-13T19:57:34Z")

</div>

Hi @fifis

To do that see the title: **Determining which `Input` has fired with** in this link:  
[https://dash.plotly.com/advanced-callbacks](https://dash.plotly.com/advanced-callbacks)

---

<div class="post-metadata">

**Author:** ![danpryjma](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@danpryjma](https://community.plotly.com/u/danpryjma)\
**Post date:** [March 15, 2021, 1:37pm UTC](https://community.plotly.com/t/create-dynamically-pages/50870/5 "2021-03-15T13:37:16Z")

</div>

Why do you need the last triggered? You could just have all pages open in a new tab or then just display the last in a Div inside your page. Divide the page in columns, show on the left the cards and the right the page, or something of the sort.

---

<div class="post-metadata">

**Author:** ![fifis](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@fifis](https://community.plotly.com/u/fifis)\
**Post date:** [March 15, 2021, 2:29pm UTC](https://community.plotly.com/t/create-dynamically-pages/50870/6 "2021-03-15T14:29:26Z")

</div>

Basically, I want the cards to display all people and then when pressed the button to open only the dashboard for this particular person. I managed to do it thanks to you @danpryjma and @Eduardo . First I changed the app1 and app2 to a function similar to the example you sent me and then in app2 layout added name. Then in the app.py created a callback which goes through all buttons, which ids I saved in a list before that in app1. And now this is working! Thank You so much, you two saved me!
