Developer forum

Forum » Development » DW8 eCom upgrade : OrderTemplateExtender override error

DW8 eCom upgrade : OrderTemplateExtender override error

Marco Johannesen
Reply
Hello DW users,

Trying to upgrade a custom Ecom soloution to DW8, and im having problems extending the OrderTemplateExtender.

Old code:
public override void ExtendTemplate(Templatev2.Template tmpl, TemplateExtenderRenderingState state) { new tags here }

New code:
public override void ExtendTemplate(Rendering.Template tmpl, TemplateExtenderRenderingState state) { new tags here }

But it gives me an error when trying to compile:
"no suitable method found to override..."

In the OrderTemplateExtender i can see they removed the following:
public virtual void ExtendTemplate(Template Template, TemplateExtenderRenderingState RenderingState);

So how do i Extend the default template in the new eCommerce version?


Replies

 
Morten Bengtson
Reply
This post has been marked as an answer
All template extenders now inherit from the base class Dynamicweb.Extensibility.TemplateExtender

TemplateExtenderRenderingState is now a property on the OrderTemplateExtender.

The OrderTemplateExtender is an abstract class, so you need to inherit from that to make your own and override the ExtendTemplate method like this...
public class MyOrderTemplateExtender: OrderTemplateExtender
{
    public override void ExtendTemplate(Template template)
    {
        if (this.RenderingState == TemplateExtenderRenderingState.After)
        {
            template.SetTag("Foo", "Bar");
        }    
    }
}
Read more about these changes here:
http://nicolaipedersen.com/blog/2012/1/dynamicweb-8-changes-to-template-extenders.aspx

UPDATE: Added rendering state to the example.

/Morten
Votes for this answer: 0
 
Marco Johannesen
Reply
Hmmm...

You right, TemplateExtenderRenderingState made the paramter error.
But since i need it to check the state, can i do it like this:

DW8 code
    public class PickNMixOrderExtender : OrderTemplateExtender
    {
        public override void ExtendTemplate(Rendering.Template tmpl)
        {
            TemplateExtenderRenderingState state = RenderingState;

            //My Code here 
        }
    }


DW7 code

	    public class PickNMixOrderExtender : OrderTemplateExtender
	    {
	        public override void ExtendTemplate(Templatev2.Template tmpl, TemplateExtenderRenderingState state)
	        {
				//My code here
			}
		}
 


 
Morten Bengtson
Reply
 Yes, I updated the sample code in my previous answer :)
 
Marco Johannesen
Reply
Thank you! :-)

 

You must be logged in to post in the forum