If I use `addToViewContextDefinition()` in an exte...
# suitecommerce
a
If I use
addToViewContextDefinition()
in an extension, how should I use that new property in an existing template? Do you just copy the template into the extension folder?
e
as a best practice the templates are separated on the theme folder, if you added a new property, identify which template will render that property and include it into the template, deploy your template changes and activate it. Then you will be able to see that property. No need to move the template.
a
So only make the template change in a theme?
s
Yes. If you're adding a new property to the context object, it can often be better to split out the functionality so that instead of doing that, you contain everything in your extension and add a new child view instead. For example, if you were going to display a new field on a PDP then the temptation is to add it to the relevant context property and then change the theme template to expose it. But you may prefer instead to simply add a new view and template and render that instead. That way you're not creating a dependency in your theme, and everything is contained within the extension.
a
That makes sense. I need to remove some things from the My Account page, so I'm assuming changing the existing template in a theme would be the only way then
s
Well it depends on what specifically you're talking about. Some things can be configured with backend settings, or with permissions.
But, yeah, the easiest/laziest 😉 way of doing it is to remove them from the template
k
If you’re making a lot of changes throughout the template then sometimes its not practical to create a childview for every instance of a context change…I think changing the template works well but add some comments.