Để viết cần thực hiện 1/ tạo file ascx : hello.ascx 2/ tạo module = hello -> def = "hello" -> control key = blank control = hello.ascx 3/ dịch module Hello ra file hello.dll 4/ copy file
Trang 1Trong frontend (giao diện trình diễn) để lấy nội dung của setting chúng ta cũng dùng string limits= Settings["limits"].ToString();
Rồi hiển thị mọi thứ bình thường như code ASP.NET
Thông thường anh em chúng ta dùng repeater và các thứ Label, Datagridview để hiển thị nội dung cần làm
Để module chạy ngon, dll cần phải copy vào thư mục /dotnetnuke/bin/ còn làm thế nào thì anh em tự nghiên cứu nhá
Tức là chúng ta sẽ có /dotnetnuke/bin/module.dll
Như vậy là đủ kiến thức để viết những module đầu tiên rồi, ví dụ module Hello world
Để viết cần thực hiện
1/ tạo file ascx : hello.ascx
2/ tạo module = hello -> def = "hello" -> control key = blank control = hello.ascx 3/ dịch module Hello ra file hello.dll
4/ copy file hello.dll vào /dotnetnuke/bin/hello.dll
5/ chọn 1 page bất kỳ rồi add module hello vào trang đó
-Coding for food
Để viết code cho 1 module chúng ta nên biết cấu trúc module của DNN
- 1 Module có n Definitions
- 1 Definition có n Controls
Trong 1 module có 2 Control đặc biệt, là các control có key = "" và key = "Settings" Control key=(blank) thì chúng ta có thể thêm nó vào 1 Page Control có key=Settings
là phần thiết lập cho module
1 Module như vậy có thể có nhiều Control cùng có key = blank, tuy nhiên khuyến cáo
là chúng ta chỉ nên dùng 1
Webiste Important to Deploy DNN
http://www.dotnetnuke.com/guidedtour/ModulesAdd.htm
List cac Module:
http://www.dotnetnuke.com/Products/Development/Forge/ModuleBlog/tabid/842/Default.asp x
Trang 2Module thuong mai dien tu la Module nao ?
Add a Module to a Page
Modules are added to a Page using the Control Panel.
Step By Step: Only the Required Steps
There are only two required steps to add a Module to a Page.
1 Select a Module from the dropdown list.
2 Click Add on the Control Panel.
The module will be added with all the default settings (visible in the Control Panel)
Trang 3Step By Step: With All the Options
Alternatively, you can change the other Settings in the Control Panel prior to adding
the page Each of these settings is optional
1 Select a Module from the dropdown list.
2 (Optional Step) Put your cursor in the Title field and type a name for your
Module This name will appear in the title area of the module container when added
to the page (as illustrated) If this field is left blank, the module name (e.g
"Text/HTML" will be substituted)
3 (Optional Step) Select the Visibility of the Page from the dropdown There are
only two possible choices
Same As Page means that the Module will be visible to any website visitor who can
see the page If your page is already visible to the public your new module will be immediately visible also
If the new module requires configuration you might choose Page Editors Only This keeps the module invisible to any website visitor who does not have Edit permissions for the Page The module is invisible to website visitors until you've had a chance to configure it The visibility can be changed in the Module Settings when it is ready
4 (Optional Step) Select the Pane of the Skin where you would like the Module to
be added The contents of the dropdown list may be different for another skin Content panes are specified by the skin designer
Trang 4The following illustration shows a Skin with a number of different Panes in various
locations and of different sizes Some panes are of a fixed size and meant for a specific purpose (such as display of a "mini banner" or a logo)
5 (Optional Step) Select where in the Pane to Insert the Module (Top or Bottom)
Modules display in a column within a pane If there are already modules in the pane, the new module will be added on the top or bottom (as specified) The module can be moved after adding it to the page if necessary
6 (Optional Step) Select how content should Align in the Module (Left, Center,
Right) Some containers do not permit the alignment to be assigned.
7 (Optional Step) Select whether to Add New Module (default) or Add Existing
Module
If you select Add Existing Module, the Page will refresh and the Module and Title fields will be replaced in the Control Panel with selectors to specify an existing Page
Trang 5and Module This function will make a "copy" of the existing module When content
is updated in the original or of any copy, the changes are reflected in all copies
8 Click Add on the Control Panel.
-Create New Module
Các bước tạo 1 module mới
Sau đây, mình xin trình bày các bước để tạo 1 module mới:
-Trong VS.NET, click lên project để chọn và sau đó nhấn chuột phải lên project, chọn Add new item Hoặc bạn có thể click lên project để chọn và trên menu, vào Website > Add new item
-Nó sẽ hiện ra 1 form mới Trong My Templates, chọn Dotnetnuke Dynamic Module -Trên Name, nhập tên module mà bạn muốn Ví dụ như MyFirstModule
-Trong language, chọn là VB hay C# tùy ngôn ngữ ưa thích của bạn
-Và click Add Khi đó sẽ có 2 thư mục được tạo ra ở 2 nơi Một thư mục là
ModuleName trong thư mục App_Code Một thự mục ModuleName trong thư mục DesktopModules
-Bạn cần đổi tên cả 2 module ModuleName đó thành MyFirstModule
-Ngoài ra, các file ở trong 2 thư mục trên ở mặc định có namespace bắt đầu bằng YourCompany Bạn có thể đổi lại theo ý của bạn như ABC bằng cách vào từng file dùng chức năng Find and Replace
-Nếu bạn chọn ngôn ngữ là C#, bạn cần làm thêm 1 bước sau đây
+Mở file web.config, bạn tìm <codeSubDirectories>.
+Thêm <adddirectoryName= " MyFirstModule " />
-Tiếp theo, bạn cần compile lại cả project
-Chạy site, bạn hãy login với quyền host Vào Host->Module Definitions.Chọn Import Module Definition Trong Manifest, chọn dnn của module bạn vừa tạo là MyFirstModule.dnn Click Import Manifest
-Vào module MyFirstModule trong DesktopModule, bạn hãy mở file
01.00.00.SqlDataProvider và copy tất cả trong đó Mở database của site trong Sql Server và run những đoạn script vừa copy được
-Cuối cùng, hãy add module vừa mới tạo ra 1 page nào đó để xem nhé
The end