How to render a partial based on route in Node Js?

Example:
I have content page in route “/product”. I want to render two component in this page.
First component on “/product” route and second is “/product/addProduct”. I use a navbar to change the route. I am changing the route internally in NODEJS. How do I render a partial based on routes ?

My site

Wappler code

Route setting

From what i understand you just need two content pages to be loaded on your two different urls - using internal links.

No, I want two partials within a single content page for different routes.

example

for “/product” == I get the content page with a partial of list of cards .
and for “/product/addproduct” == I should get a partial with a form in it. This should all take place with the single content page.

Partials are not really meant to be used this way.
You need two content pages loaded in your layout - one containing your list of items and another one containing a form.

Partials are used for reusing data like - header/footer across multiple pages. You can’t load partials in the routes as in your screenshots above.

I have other components like navbar which will be common for both content page. I will have to copy the component code to both pages right ?

Now that's where you use partials :slight_smile: Place your common elements in a partial and add them to both of your pages.

1 Like

The navbar would be a partial.

1 Like