[转]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 ...
随机推荐
- java对cookie的操作
java对cookie的操作比较简单,主要介绍下建立cookie和读取cookie,以及如何设定cookie的生命周期和cookie的路径问题. 建立一个无生命周期的cookie,即随着浏览器的关闭即 ...
- SQL SERVER 2008 R2 SP1更新时,遇上共享功能更新失败解决方案
SQL SERVER 2008 R2 SP1更新时,遇上共享功能更新失败的问题,可作如下尝试: 更新失败后,在windows的[事件查看器→应用程序]中找到来源为MsiInstaller,事件ID为1 ...
- 创业小坑:内网域名 在windows下能nslookup,但ping不通,也无法访问。而在linux下正常。
使用巴法络(BUFFALO )LS-XL 网络硬盘盒开启了FTP服务,IP是172.16.0.21 在windows和linux上,都可以访问ftp://172.16.0.21,现在想使用域名访问,便 ...
- Tab切换类型
Tab切换类型 点击Tab 滑过Tab 延迟Tab CSS样式 ; ; list-style:none; font-size:12px;} .notice{width:298px; height:98 ...
- store.js - 轻松实现本地存储(LocalStorage)
store.js 是一个兼容所有浏览器的 LocalStorage 包装器,不需要借助 Cookie 或者 Flash.store.js 会根据浏览器自动选择使用 localStorage.globa ...
- 总结的一些微信API接口
本文给大家介绍的是个人总结的一些微信API接口,包括微信支付.微信红包.微信卡券.微信小店等,十分的全面,有需要的小伙伴可以参考下. 1. [代码]index.php <?php include ...
- SPS中JSOM和SOAP 实现文件上传
一.HTML控件 <input type="file" id="upFile" style="width:300px;"/> & ...
- XMPP学习——3、XMPP协议学习补充
流基础 两个基本概念,使得XMPP实体之间的小的结构化信息有效载荷能快速地进行异步交换:XML流和XML节.这些术语的定义如下. XML流的定义: XML流是一个容器,用于任何两个实体通过网络进行XM ...
- AES加密解密
AES简介 美国国家标准技术研究所在2001年发布了高级加密标准(AES).AES是一个对称分组密码算法,旨在取代DES成为广泛使用的标准. 根据使用的密码长度,AES最常见的有3种密钥方案,用以适应 ...
- MVC 生成图片,下载文件
/// <summary> /// 生成图片 /// </summary> /// <param name="collection"></ ...