[转]simple sample to create and use widget for nopcommerce
本文转自: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 } }; } |
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} }; } |
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的更多相关文章
- 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 ...
- SSAS-many 2 many one simple sample
基本业务:一个事件发生后,影响到多个国家,这个事件也会被定一个事件类型(这里简化为type1,2,3),处理这个事件花费多长时间. 我们的事实表就记录这个事情,相对应的我们设计两个维表,一个是国家,一 ...
- [Flutter] Create a Customer widget
For example, we want to have to button, looks similar to FloatingActionButton: But in the doc, it sa ...
- ASP.NET MVC 4 WebAPI Simple Sample
// Controllers.cs namespace Microshaoft.WebApi.Controllers { using Microshaoft.WebApi.Models; using ...
- Flutter 即学即用系列博客——06 超实用 Widget 集锦
本篇文章我们来讲讲一些比较常用的 Widget. 大家验证的时候使用下面的代码替换 main.dart 代码,然后在 //TODO 语句返回下面常用 Widget 示例的代码. import 'pac ...
- [转]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/ ...
- 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 ...
- hdu4975 A simple Gaussian elimination problem.(正确解法 最大流+删边判环)(Updated 2014-10-16)
这题标程是错的,网上很多题解也是错的. http://acm.hdu.edu.cn/showproblem.php?pid=4975 2014 Multi-University Training Co ...
- Calculating simple running totals in SQL Server
Running total for Oracle: SELECT somedate, somevalue,SUM(somevalue) OVER(ORDER BY somedate ROWS BETW ...
随机推荐
- 02Mybatis_原生态jdbc编程中的问题总结——从而引生出为什么要用Mybatis
我们先用jdbc去编写一个例子: 第一步:建表 /* SQLyog v10.2 MySQL - 5.1.72-community : Database - mybatis ************** ...
- 小清新的jQuery ck-slide 图片轮播
ck_slide 是一款小清新的jQuery 幻灯片插件,它非常小巧,压缩后仅 3KB,基本功能可以满足.它支持淡入淡出/左右滚动.箭头/圆点控制.自动播放. 在线实例 默认(淡入淡出) 左右滚动 自 ...
- Subway Icon Set – 306个像素完美的特制图标
这个图标集是306个优化的像素完美,精雕细琢的图标.为这些设备进行了优化:iOS.Windows Phone.Windows 8 and BlackBerry 10,提供 PNG, SVG, XALM ...
- javascript中关于数组的一些鄙视题
一.判断一个数组中是否有相同的元素 /* * 判断数组中是否有相同的元素的代码 */ // 方案一 function isRepeat1(arrs) { if(arrs.length > 0) ...
- 在不知下面有几个元素的时候,要去除最后一个元素的下边框jquery代码
<script> $(document).ready(function() { $(".search_list dl").each(function() {//遍历所有 ...
- ViewPager的使用小技巧
1.在ViewPager中默认加载当前屏幕上的界面和左右相邻界面的数据从而实现页面滑动的快速切换.可以通过调用setOffscreenPageLimit(int)方法,定制预加载相邻页面的数目. 2. ...
- Android实现与PHP服务器的交互
今天算是有点小激动呢!拿到Android与PHP这个课题已经两个星期了,直到今天才算是有了一点点小收获. 虽然还是没能成功上传到服务器,不过已经看到了曙光,已经实现了一半了,那就是已经连接到了服务器. ...
- 极其简单的搭建eclipse的android开发环境
这篇博客是关于如何搭建eclipse的android开发环境, 与网上的其他博客不同,我的方法比他们简单的多,所 以推荐给大家. 搭建eclipse的android开发环境步骤: 1.配置JDK(Ja ...
- Android常用抓包工具之TcpDump
➠更多技术干货请戳:听云博客 做为一个测试人员,工作中经常会用到数据抓包工具来进行数据分析和验证,下面就简单介绍一下工作中常用的抓包工具. TcpDump抓包 Tcpdump是一个用于截取网络分组,并 ...
- Objective—C基础学习总结
1. (1)面向过程:一种以事件为中心的编程思想 (2)面向对象:一种以对象为中心的编程思想 2.get和set是用来访问和修改对象里的属性值 ...