Download nhạc từ các trang nhạc lớn của Việt Nam

24 Tháng Mười Một 2006
@ 04:28
(Tác giả:Phạm Đức Hải)

Từ phiên bản dasBlog 1.8, nó cho phép tạo ra các macros giống như các plugin.
Tôi cũng thử làm một cái xem sao happy

Bước 1 : Dùng VS 2003 hoặc 2005 đều được tùy phiên bản chạy trên web là .NET 1.x hay .NET 2.0

Tạo project mới loại "Class Library", với tên là MyMacros

Bước 2 : Thêm 2 assembly newtelligence.DasBlog.Runtime.dll, newtelligence.DasBlog.Web.Core.dll.

Bước 3 : Tạo class Macros.cs, code như sau :

Phần thư viện :

   1:  using System;
   2:  using System.Web.UI;
   3:  using newtelligence.DasBlog.Runtime;
   4:  using newtelligence.DasBlog.Web.Core;

Phần code chi tiết một hàm, ví dụ hàm EmailIt:

   1:  public virtual Control EmailIt(string linkText)
   2:  {
   3:      if (this.currentItem != null)
   4:      {
   5:          string text1 = ";";
   6:          if (this.currentItem.Link != null)
   7:          {
   8:              text1 = this.currentItem.Link;
   9:          }
  10:          else
  11:          {
  12:              text1 = Utils.GetPermaLinkUrl(this.currentItem);
  13:          }
  14:          return new LiteralControl("<a target=\"_blank\" class=\"mailLinkStyle\" 
href=\"mailto:?subject=" + this.currentItem.Title+"&body=Toi thay bai nay rat hay: "+ 
text1 +". Hy vong la ban cung thich.\""+ "\">" + linkText + "</a>");
  15:      }
  16:      return new LiteralControl("");
  17:  }

Sau đó dịch thành .dll file, bạn sẽ có file MyMacros.dll.

Bước 4 : Sử dụng macro vừa tạo

Copy file MyMacros.dll vào thư mục bin của web, sau đó trong file config sửa thông tin như sau :

- Bỏ commnet dòng :

<section name="newtelligence.DasBlog.Macros" 
type="newtelligence.DasBlog.Web.Core.MacroSectionHandler, newtelligence.DasBlog.Web.Core" />

- Bỏ comment và thêm dòng :

<newtelligence.DasBlog.Macros>
<add macro="mymacros" type="MyMacros.Macros, MyMacros"/>
</newtelligence.DasBlog.Macros>

Tiếp theo trong phần template file sử dụng bằng cách thêm :

<%EmailIt("Gửi tặng")|mymacros%>

Lưu ý là CSS class mailLinkStyle bạn cũng phải thêm vào trong CSS file của web.
và đây là kết quả :
macro.JPG
Các bài viết cần tham khảo :
Creating custom macros for dasBlog
Creating Macros for dasBlog