How can I create a NopCommerce plugin to manipulate or change the output HTML.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
I want to create a NopCommerce plugin to manipulate the output HTML.
For ex say we have an image tag
<img href="http://mytestsite/testimage.jpg" alt=""/>

and I want to replace all occurrence of "http://mytestsite" to "http://mynewsite" on the output HTML and I want to do this using a Plugin.

Can anyone help me out on this.

Thanks
6 years ago
NikhilAccuWeb wrote:
I want to create a NopCommerce plugin to manipulate the output HTML.
For ex say we have an image tag
<img href="http://mytestsite/testimage.jpg" alt=""/>

and I want to replace all occurrence of "http://mytestsite" to "http://mynewsite" on the output HTML and I want to do this using a Plugin.

Can anyone help me out on this.

Thanks


You can create widget plugin that plugin will be push a js into you theme. And you will write  replace logic of "http://mytestsite" to "http://mynewsite" in that js.
6 years ago
sohel wrote:
I want to create a NopCommerce plugin to manipulate the output HTML.
For ex say we have an image tag
<img href="http://mytestsite/testimage.jpg" alt=""/>

and I want to replace all occurrence of "http://mytestsite" to "http://mynewsite" on the output HTML and I want to do this using a Plugin.

Can anyone help me out on this.

Thanks

You can create widget plugin that plugin will be push a js into you theme. And you will write  replace logic of "http://mytestsite" to "http://mynewsite" in that js.


I agree with this logic but our JS logic will call after page loaded and then replace the URL so i think when JS will replace the url then it will crash all images etc as i don't think that it will request the image with new url and load it.

so replace logic should execute before the content is loaded as once it loaded and if we change the url then it will crash as it will not get the content from server with new url once page is content is loaded already.
6 years ago
vipul.dumaniya wrote:
I want to create a NopCommerce plugin to manipulate the output HTML.
For ex say we have an image tag
<img href="http://mytestsite/testimage.jpg" alt=""/>

and I want to replace all occurrence of "http://mytestsite" to "http://mynewsite" on the output HTML and I want to do this using a Plugin.

Can anyone help me out on this.

Thanks

You can create widget plugin that plugin will be push a js into you theme. And you will write  replace logic of "http://mytestsite" to "http://mynewsite" in that js.

I agree with this logic but our JS logic will call after page loaded and then replace the URL so i think when JS will replace the url then it will crash all images etc as i don't think that it will request the image with new url and load it.

so replace logic should execute before the content is loaded as once it loaded and if we change the url then it will crash as it will not get the content from server with new url once page is content is loaded already.


If you want to change storelocation for the case of image url only then you can override PictureService's GetPictureUrl() like below from plugin

public override string GetPictureUrl(Picture picture,
            int targetSize = 0,
            bool showDefaultPicture = true,
            string storeLocation = null,
            PictureType defaultPictureType = PictureType.Entity)
        {
            storeLocation = "NewStoreLocation";

.....}
6 years ago
Thanks Sohel and Vipul for your valuable reply.

Basically I want LazyLoad feature in a plugin which makes browsers not load images until they scroll into view, therefore saving bandwidth.

I want to create a plugin for this. So is it possible.

I have searched regarding this and I get this link
https://www.nopcommerce.com/p/1343/nopservices-lazy-load-plugin.aspx

But it redirect to 404.

Please help me out on this.

Thanks
6 years ago
NikhilAccuWeb wrote:
Thanks Sohel and Vipul for your valuable reply.

Basically I want LazyLoad feature in a plugin which makes browsers not load images until they scroll into view, therefore saving bandwidth.

I want to create a plugin for this. So is it possible.

I have searched regarding this and I get this link
https://www.nopcommerce.com/p/1343/nopservices-lazy-load-plugin.aspx

But it redirect to 404.

Please help me out on this.

Thanks


You should use third party js libraries like ==>http://appelsiini.net/projects/lazyload/
6 years ago
sohel wrote:
Thanks Sohel and Vipul for your valuable reply.

Basically I want LazyLoad feature in a plugin which makes browsers not load images until they scroll into view, therefore saving bandwidth.

I want to create a plugin for this. So is it possible.

I have searched regarding this and I get this link
https://www.nopcommerce.com/p/1343/nopservices-lazy-load-plugin.aspx

But it redirect to 404.

Please help me out on this.

Thanks

You should use third party js libraries like ==>http://appelsiini.net/projects/lazyload/


But I want to create a plugin for this.

Thanks
6 years ago
Only way to change a cshtml page without touching the coren is to make your custom controller in a plugin and use ActionFilters to capture the default action and map to your own controller action and views.

Search the forums for ActionFilters and how to use them
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.