Hi,
Just discovered how to write custom tagextensions (with Razor fallback) and was very happy, however I discover that it does not work on custom tags.
Why is that?
Med venlig hilsen/Best regards,
Sten Hougaard
Webudvikler
Hi,
Just discovered how to write custom tagextensions (with Razor fallback) and was very happy, however I discover that it does not work on custom tags.
Why is that?
Med venlig hilsen/Best regards,
Sten Hougaard
Webudvikler
Can you provide an example?
Not a concrete example. Imagine that a custom tag exists, say: firstweb:Hello.Price
I want to do some solution related post parsing of say prices, something which should apply to some prices (not all) shown on the website.
Imagine a "pretty" price, like "19995,00" should be shown as "19.995,-" and we build a tag extension "PrettyPrice()".
The custom tag would then be extended the tag extension: firstweb:Hello.Price.PrettyPrice()
The price from that tag will not become a pretty price, but a standard Dynamicweb eCom tag will become a pretty price.
/Sten
This works for me on Dynamicweb 8.4.1:
using Dynamicweb; using Dynamicweb.eCommerce.Products; using Dynamicweb.Rendering; using Dynamicweb.Extensibility; namespace TemplateExtenders { public class CustomTemplateExtender : ProductTemplateExtender { public override void ExtendTemplate(Dynamicweb.Rendering.Template template) { template.SetTag("custom:tag", 1.23); } } [AddInName("debug")] public class TagExtensionMethodTest : TagExtensionMethod { public override string ExecuteMethod(string value) { // @TODO Do something with value return System.Net.WebUtility.HtmlEncode(Newtonsoft.Json.JsonConvert.SerializeObject(new { value = value, self = this })); } } }
Use in template:
<pre>@custom:tag: <!--@custom:tag--> @custom:tag.debug(): <!--@custom:tag.debug()--> @custom:tag.debug(a, b, c): <!--@custom:tag.debug(a, b, c)--> </pre>
Best regards,
Mikkel
Hi Mikkel,
Great - thank you. We are on this customer coding on an older DW version (Dynamicweb.dll 8.3.1.11) so I guess it makes sense, so I hope!
/Sten
You must be logged in to post in the forum