本文转自: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. PCL -语法错误:“::” error C2589: “(”:“::”右边的非法标记

    1.错误原因:系统函数与pcl中的max函数冲突导致的 2.两种解决办法: 1)错误中max和min函数用括号括起来,例如"std::Max"修改为“(std::Max)”. 2) ...

  2. 2013年最新流行的响应式 WordPress 主题【上篇】

    WordPress 是最流行的内容管理系统,经历了多年的发展和演变.它的成功体现在庞大的社区,数百万的用户,设计师和开发者推动着 WordPress 往更高的层次发展. 海量的免费主题是 WordPr ...

  3. 【初探移动前端开发03】jQuery Mobile(上)

    前言 到目前为止,我打了几天酱油了,这几天落实了工作,并且看了一部电视连续剧(陈道明-手机),我很少看连续剧了,但是手机质量很高啊,各位可以看看. 我们今天先学习一下jquery mobile的基础知 ...

  4. Linux 常见命令说明

    目前由于自己接触到的是 windows 的操作系统,所以会经常使用 git bash 来提交代码到 github上. git bash 是 windows 下模拟 Linux 的命令行工具. 在此总结 ...

  5. javascript 函数初探 (六)--- 闭包初探#1

    首先我们来看一个函数: var a = 'global variable'; var F = function(){ var b = 'local variable'; var N = functio ...

  6. 关于Canvas模糊的问题

    前言:当我在几个多月前,第一次在移动设备上使用canvas绘制内容的时候,我惊然地发现我绘制的图片以及文字居然都是模糊的!我的内心几乎是崩溃的,因为那是我第一个使用canvas的项目,是一个基于微信端 ...

  7. Ubuntu开机黑屏,无法进入系统

    今天早上起来开机发现Ubuntu进不去了,启动项选择之后长时间的black of screen,击键盘.点鼠标毫无反应,后来实在等不下去了就按了一下电源键,以平时的性格就是强制关机的,这次轻轻碰一下就 ...

  8. 转-Nmap扫描原理与用法

    1     Nmap介绍 操作系统与设备类型等信息. Nmap的优点: 1.      灵活.支持数十种不同的扫描方式,支持多种目标对象的扫描. 2.      强大.Nmap可以用于扫描互联网上大规 ...

  9. Phonegap之ios对iPhone6和Plus的闪屏适配 -- xmTan

    故事的发生起于,由于老板强烈要求app在iPhone6和5有一样的工具栏,然后前端妹子用@media为iPhone6和Plus做了样式适配.然后问题来了,竟然奇葩的发现@media样式只对iPhone ...

  10. 通过settings.db自定义Android系统默认设置

    Android的系统设置数据存放在/data/data/com.android.providers.settings/databases/settings.db 中 数据库结构如下: 数据库中的默认数 ...