Routing to another template

Hi, i have a problem i want redirect from my homepage to another template. i have made a new template with an id=2 and a template variable named ‘cart’ and assigned to the ‘cart’ template the template exists in the modx_site_templates. I have placed some content to render an cart checkout. this is my code: <a href="[[~2]]" class="cart-item" id="cart-item">Cart Item</a> that i have placed in my navigation banner. but when i click on the link the page is reloading. i get nothing in my network tab that i can see that there is loading a new page. what am I doing wrong?

This creates a link to the resource with the ID = 2.
You probably have to create a new resource, and assign your new template to that resource.

i have created a new template with an id=3 and assigned the template to the template variable cart. but when i set [[~3]] the redirect is not working…

I think you are mixing up templates and resources.

Resources are your web pages. They have a specific URL. For every resource, you can choose which template to use for it.

A template is the basic structure for a page, that can be used by many resources/pages.
For example: If your site has several products, you can create a template Product and then use this template for all your product pages (“Product A”, “Product B”, etc.).

A template has no URL and can’t be called directly. You have to create a resource for that.

3 Likes

Thanks for the clear explanation. I am just started with Modx.