本文转自:http://badpaybad.info/simple-sample-to-create-and-use-widget-for-nopcommerce

Here is very simple code to create widget in nopcommerce
First you can download nopcommerce version 3.70 in here http://www.nopcommerce.com/downloads.aspx Seconds you should read bellow link http://docs.nopcommerce.com/display/nc/How+to+write+a+nopCommerce+plugin Third download project sample widget for nopcommerce  here http://badpaybad.info/upload/nopcommerce/Nop.Plugin.BadPayBad.HelloWorld.zip Then extract and copy to folder plugins.  then add it to solution similar to image bellow
the output path for project will use in controller to return view (the file .cshtml) image for output path when build http://badpaybad.info/upload/nopcommerce/nopcommercewidget9.png
public class HelloWorlWidgetNopPlugin : BasePlugin, IWidgetPlugin [big image]  
As you can see in project sample. it very sample .cshml file . I just show the text hello world
The file HelloWorlWidgetNopPlugin.cs contain the defind of where is the action and controller for admin mode (the admin view) and frontend (the visitor view)
- Admin mode: the defind interface for admin can access to do some config defind by bellow

1
2
3
4
5
6
7
8
9
10
11
public void GetConfigurationRoute(out string actionName, out string controllerName,
           out RouteValueDictionary routeValues)
       {
           actionName = "Configure";
           controllerName = "BadPayBadHelloWorld";
           routeValues = new RouteValueDictionary()
           {
               { "Namespaces", "Nop.Plugin.BadPayBad.HelloWorld.Controllers" },
               { "area", null }
           };
       }
- The front end mode: mean we show something for user visit the page

1
2
3
4
5
6
7
8
9
10
11
12
public void GetDisplayWidgetRoute(string widgetZone, out string actionName, out string controllerName,
            out RouteValueDictionary routeValues)
        {
            actionName = "FrontEndView";
            controllerName = "BadPayBadHelloWorld";
            routeValues = new RouteValueDictionary
            {
                {"Namespaces", "Nop.Plugin.BadPayBad.HelloWorld.Controllers"},
                {"area", null},
                {"widgetZone", widgetZone}
            };
        }
- Then you need register the name, region of widget will use in frontend

  
1
2
3
4
public IList<string> GetWidgetZones()
   {
       return new List<string>() { "home_page_top_badpaybad_hello"};
   }

The controller for this widget 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace Nop.Plugin.BadPayBad.HelloWorld.Controllers
{
    public class BadPayBadHelloWorldController : BasePluginController
    {
        public ActionResult Configure()
        {
            var model = new object();
            //..\..\Presentation\Nop.Web\Plugins\BadPayBad.HelloWorld\
            //the view file .cshml depend your output path
            return View("~/Plugins/BadPayBad.HelloWorld/Views/BadPayBadHelloWorld/Configure.cshtml", model);
        }
 
        public ActionResult FrontEndView()
        {
            var model = new object();
            //..\..\Presentation\Nop.Web\Plugins\BadPayBad.HelloWorld\
            //the view file .cshml depend your output path
            return View("~/Plugins/BadPayBad.HelloWorld/Views/BadPayBadHelloWorld/FrontEndView.cshtml", model);
        }
    }
}
 

How to use it  to display in the view for visitor can see  place this code into view you want, eg: index.cshtml in home folder . just render widget with the name defined rebuild you nopcommerce solution but it not display yet. you must install widget and active it in admin mode @Html.Widget("home_page_top_badpaybad_hello")


Install widget in nopcommerce: go to admin, -> configutration -> plugins -> local plugins Click install the widget you will have similar bellow image

active widget in nopcommerce
go to admin, Content management -> widgest  then find your widget. edit and check to active button similar to bellow image  All done.


Then the result will have hello world text display in front end

if you go to the plugin then click config you will have similar bellow :) it nothing else excepted hello world go to nopcommerce admin, -> configutration -> plugins -> local plugins Then click config

you also can enable (active) nopcommerce widget in  go to nopcommerce admin, -> configutration -> plugins -> local plugins By click into edit button

Finally I hope you guys can do more for your need this is very simple sample to create and use widget in nopcommerce Thank your for your reading.

[转]simple sample to create and use widget for nopcommerce的更多相关文章

  1. Create a Qt Widget Based Application—Windows

    This turtorial describes how to use Qt Creator to create a small Qt application, Text Finder. It is ...

  2. SSAS-many 2 many one simple sample

    基本业务:一个事件发生后,影响到多个国家,这个事件也会被定一个事件类型(这里简化为type1,2,3),处理这个事件花费多长时间. 我们的事实表就记录这个事情,相对应的我们设计两个维表,一个是国家,一 ...

  3. [Flutter] Create a Customer widget

    For example, we want to have to button, looks similar to FloatingActionButton: But in the doc, it sa ...

  4. ASP.NET MVC 4 WebAPI Simple Sample

    // Controllers.cs namespace Microshaoft.WebApi.Controllers { using Microshaoft.WebApi.Models; using ...

  5. Flutter 即学即用系列博客——06 超实用 Widget 集锦

    本篇文章我们来讲讲一些比较常用的 Widget. 大家验证的时候使用下面的代码替换 main.dart 代码,然后在 //TODO 语句返回下面常用 Widget 示例的代码. import 'pac ...

  6. [转]create a basic sql server 2005 trigger to send email alerts

    本文转自:http://blog.netnerds.net/2008/02/create-a-basic-sql-server-2005-trigger-to-send-e-mail-alerts/ ...

  7. Python 对不均衡数据进行Over sample(重抽样)

    需要重采样的数据文件(Libsvm format),如heart_scale +1 1:0.708333 2:1 3:1 4:-0.320755 5:-0.105023 6:-1 7:1 8:-0.4 ...

  8. hdu4975 A simple Gaussian elimination problem.(正确解法 最大流+删边判环)(Updated 2014-10-16)

    这题标程是错的,网上很多题解也是错的. http://acm.hdu.edu.cn/showproblem.php?pid=4975 2014 Multi-University Training Co ...

  9. Calculating simple running totals in SQL Server

    Running total for Oracle: SELECT somedate, somevalue,SUM(somevalue) OVER(ORDER BY somedate ROWS BETW ...

随机推荐

  1. Quartz.NET开源作业调度框架系列(四):Plugin Job

    如果在Quartz.NET作业运行时我们想动态修改Job和Trigger的绑定关系,同时修改一些参数那么该怎么办呢?Quartz.NET提供了插件技术,可以通过在XML文件中对Job和Trigger的 ...

  2. javascript --- 设计模式之创造者模式

    在软件系统中,有时候面临着“一个复杂对象”的创建工作,其通常由各个部分的子对象用一定的算法构成:由于需求的变化,这个复杂对象的各个部分经常面临着剧烈的变化,但是将它们组合在一起的算法确相对稳定.如何应 ...

  3. 100个高质量Java开发者博客

    ImportNew注:原文中还没有100个.作者希望大家一起来推荐高质量的Java开发博客,然后不段补充到这个列表.欢迎你也参与推荐优质的Java开发博客.(声明一下:我们的数学不是体育老师教的!:) ...

  4. Android 播放在线视频

    首先开启电脑上的tomcat,将视频文件放在Tomcat 7.0\webapps\ROOT中 不用修改代码,直接输入地址即可,运行如下: 播放在线视频,必须要求手机支持当前的格式,才可以播放 播放的原 ...

  5. ios 取出subviews中指定subview

    for(UIView *view in subviews){ if(view.tag == 998) { //根据tag判断 } if([view isKindOfClass:[UIImageView ...

  6. objective-c系列-NSDictionary&NSMutableDictionary

    ********************************************* NSDictionary ***************************************** ...

  7. iOS开发--Swift 基于MVC设计模式的简单的tableViewDemo

    如果说MVC是最好的设计模式, 可能很多人并不赞同, 但是如果说MVC是最主流, 应用面最广的设计模式, 我想这是毫无争议的. 不说废话, 直接演示在Swift中如何使用MVC新建工程(我并没有新建文 ...

  8. 【代码笔记】iOS-点击顶点处,弹出另一个小的界面

    一,效果图. 二,文件目录. 三,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewControlle ...

  9. OC中UITabBarController控制器

    UITabBarController UITabBarController(记为O)常用于管理多个导航控制器,例如有ABC三个导航控制器,可以:addChildViewController(记为A), ...

  10. 【VLC-Android】Mac下编译vlc-android

    前言 突然想整整VLC-Android,然后就下一个玩玩看,这里记录点遇到的问题. 声明 欢迎转载,但请保留文章原始出处:)  博客园:http://www.cnblogs.com 农民伯伯: htt ...