Hi there,
I have a site that uses assortments. With the assortment, some products are not available to users that are logged in, but they are available for anymous users. When a logged in user looks at one of those products (for example, from a Text and Image item with a product), the link to the product is broken / does not exist (it has ?MainProductId= as the query string instead of a product reference).
I can fix that with code like this in my paragraph template:
if (!productIds.Any()) { return new Dynamicweb.Frontend.LinkViewModel() { Url = "/Default.aspx?ID=" + SomeIdIWantToRedirectTo IsExternal = false }; }
However, I have this code in at least 8 templates; all of them from standard Swift I believe? (Search for string productParameter = productIds.Count == 1 ? "ProductID" : "MainProductId"; to see what I mean) Why?? A simple code fix now suddenly affects 8 templates which I all need to copy as custom, change, assign to item types as defaults in every site that uses them, add them to Git and maintain them forever Grrrrrrr. And to make it even worse: some templates like Text and Image repeat this code block *in* the same template!
Surely there must be a better way than repeating all this code in every template? Surely there must be a better way than repeating all this code in every template?
Imar