Luyenkim.Net!

...where your idea grows!

 
  • Decrease font size
  • Default font size
  • Increase font size
Trang chủ arrow DIỄN ĐÀN
Luyện kim
Banner
Re:Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm
#2002
viet4777
(User)
Giáo chủ Luyenkim.NET
Expert Boarder
Posts: 165
graphgraph
User Offline Click here to see the profile of this user
Gender: Male viet47777 viet47777 Birthdate: 1977-07-04
Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 5 Months, 1 Week ago Karma: 1  
Dường như việc viết chương trình trong Joomla 1.5.x hầu như khá đơn giản. 1 mô tả giống như 1 đứa trẻ chơi trò chơi Lego:
Có 1 số giới hạn các block nguyên thủy (thành phần hàm nhỏ nhất), bằng sự tinh nghịch và sự sáng tạo của bé. Nó có thể xếp và tạo nên những hình khối độc đáo từ đơn giản đến phức tạp.

Tuy nhiên vói 1 hình khối, có bé chỉ cần 1 số lượng block tối thiểu để dựng nên nhưng có bé lại cần 1 nhiều hơn thế...

Tham khảo ví dụ:
http://api.joomla.org/Joomla-Framework/Utilities/JString.html


Mấy plugin đang viết sẽ chuyển sang Joomla thuần: nghĩa là chỉ sử dụng các hàm từ Joomla! Framework.

Xem thêm: http://xahoihoctap.net/component/op...tid,9/id,437/lang,en/#403
 
Report to moderator   Logged Logged  
 
Nguyễn Hoàng Việt
  The administrator has disabled public write access.

Liên kết website

Thư viện cộng đồngbuaxua.vnjoomlaviet.orgvnfolk.comSửa ĐTDD
#2005
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 672
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Re:Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 5 Months, 1 Week ago Karma: 3  
Bắt đầu từ tháng này (2008-05-10) vào các ngày cuối tuần (T7 hoặc CN) tôi sẽ giới thiệu các dịch vụ hay các gói hàm đơn giản sử dụng trong quá trình viết "mở rộng" cho Joomla 1.5.x và các ví dụ đơn giản khi viết 1 plugin và module, hay component.

Bài 1: Sử dụng JText, JString và JDate - Tự viết 1 plugin để chơi file nhạc MP3



Tham khảo: http://docs.joomla.org/How_to_create_a_content_plugin
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#2027
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 672
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Re:Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 5 Months ago Karma: 3  
Đây là toàn bộ nội dung code của plugin sử dụng để tạo chương trình Flash chơi file nhạc mp3.
Plugin có chứa 4 file:
+ File plg_mp3.php - file chuơng trình chính.
+ File plg_mp3.xml file khai báo các file trong gói và các tham số của plugin
+ mp3.swf và player.swf là 2 file flash để chơi file nhạc mp3.
Code:

# Archive plg_content_mp3.zip
2008-05-10 19:44 Folder Folder plg_mp3
2008-05-10 02:30 35118 35128 plg_mp3\mp3.swf
2008-05-10 02:30 5260 5260 plg_mp3\player.swf
2008-05-10 03:37 4967 2044 plg_mp3.php
2008-05-10 02:38 1470 617 plg_mp3.xml
#
# Total Size Packed Files
# 46815 43049 5


Tải plugin plg_content_mp3.zip:
File Attachment:
Please login to download the file!
File Size: 43577


Chức năng: thay khế các TAG có dạng {xmp3 title="tiêu đề" type="1"}link đến file mp3{/xmp3}
Các tham số title và type là option nên có hay không cũng không sao.

Bằng các mã object (embed) tương ứng để phát sinh chưong trình Flash để play file nhac mp3.

Demo: http://xahoihoctap.net/webs/joomla1...-website-nay.html?start=1

Code:

1. {xmp3 title="Thử nghiệm plugin plg_content_mp3"}{/xmp3}
2. {xmp3 type="1"}{/xmp3} - Title sẽ được lấy từ title của file mp3
Khi không chỉ rõ link, link mặc định sẽ được sử dụng.



Cài đặt và sử dụng:
  • Đăng nhập với chức năng quản trị.
    Chọn menu Extensions/Install/Uninstall
  • Nhấn nút Browser để chọn file cài đặt plg_content_mp3.zip
    Sau đó nhấn nút Upload file & Install để bắt đầu cài đặt. Nếu bạn thấy lời chào mừng và thông báo cài đặt thành công, nghĩa là bạn đã cài đặt thành công!
  • Chọn menu Extensions/Plugin Manager.
    Chọn plugin có tên "Content - Mp3 Plugin", sau đó thiết lập plugin với Enable là On,
    và thiết lập 2 tham số mặc định mp3 url và Default title.
  • Nhấn nút Save để lưu các thay đổi và kết thúc thiết lập cho plugin.
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#2030
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 672
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Re:Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 5 Months ago Karma: 3  
Phân tích code của plugin trong gói plg_content_mp3.zip.

Để hiểu rõ hơn, các bạn có thể tham khảo thêm tại đây:
  1. http://forum.joomla.org/viewtopic.php?f=478&t=233628
  2. http://forum.joomla.org/viewtopic.php?f=478&t=233628


Cấu trúc của file plg_mp3.xml: Tất cả các plugin đều phải tuân theo 1 quy tắc chung. Nên chúng ta chỉ cần xét các điểm riêng biệt.

Các dòng 1 và 2 là quy định bắt buộc. Giống như bạn nói 1+1=2.

Dòng 3 là khai báo dạng thức mở rộng: có kiểu là plugin và nhóm là content (các nhóm khác như system, search,...).

Từ dòng 4-12 là các dòng mô tả sản phẩm: tác giả, mã nguồn mở hay thương mại, và mô tả sản phẩm.

Dòng 13-17: Khai báo các files sẽ được upload lên host sẽ sử dụng. Mặc định file plg_mp3.php sẽ được upload vào thư mục plugins/content/, đây là file chuơng trình chính. Còn 2 file mp3.swf và player.swf sẽ được upload vào thư mục plugins/content/plg_mp3/. Hai file flash sẽ được sử dụng để tạo mp3 Player trên website.

DÒng 18-25: Khai báo tham số, có 3 tham số enabled, src và title. Tham số enable có tác dụng như sau - nếu là On (1), plugin sẽ làm việc như đã nói ở trên, là thay thế 1 mẫu kí tự cho trước bằng mẫu ký tự mới. Nếu là off (0), plgun sẽ xóa các mẫu ký tự nó tìm thấy trong bài viết. Chú ý, khác với plugin được publish, nếu plugin được publish - nó sẽ thao tác như 2 trường hợp của tham số enable nói trên. Nếu k0 publish, các mẫu câu đó k0 bị tác động gì cả.
Tham số thứ 2 - src - tham số này là giá trị link đến file nhạc mặc định nếu bạn k0 cung cấp link theo dạng {xmp3 tham số}{/xmp3}. Còn dạng {xmp3}link_to_music{/xmp3} thì giá trị src này bị bỏ qua.
Tuơng tự cho tham số thứ 3 - title - được sử dụng làm title mặc định khi tham số title k0 xuất hiện trong mẫu.

Dòng 3 và 26 là dấu hiệu mở đầu và kết thúc phần cài đặt của plugin.
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#2049
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 672
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Re:Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 5 Months ago Karma: 3  
Plugin - Suggested Approach - Best Practise

New postby kgcollector on 04 May 2008, 12:44:45 on Joomla.org
I am looking for some information / guide lines or advise on the best practise for plugin in Joomla 1.5.x. I have been unable to locate any documentation to help (which may be user error with me searching in the wrong places)

I have now looked at many different code example of how people have implemented the parameters available to a user when typing then into the content item.

Below are some of the variations I have come across from other plugins

{loadmodule user1}
{plugin}param1{/plugin}
{plugin param1="value"}param2 {/plugin}
{plugin param1="value" para2="value2"}param3=value 2&param4=value4 {/plugin}

So my questions are:
1 - What is the Joomla recommended approach (or does it not matter)?
2 - How best to extract the parameters? Are there any joomla utilities/helpers to do this or is it just manual manipulation of the string (rg split/ arrays etc)

Any help / input would be appreciated

It should be: I think it's the best way to approach!
{plugin param1="value" para2="value2"....}main_infor_just_one_param{/plugin}

Almost functions are included in Joomla 1.5.x Frame-work.

Determine the plugin in article:
Code:

$regex = "#{plugin*(.*?)}(.*?){/plugin}#s";
if (preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER) > 0) {
foreach ($matches as $match) {
Doing something here!
}
}

Extract the parameters:
Code:

//This code should be done inside of foreach ($matches as $match) {

$plg_params = & JUtility::parseAttributes($match[1]); //It will read and extract each parameter.
//access param1:
$plg_params['param1']...//will give "value" as above example.


//Get default params from plugin:
$theplugin =& JPluginHelper::getPlugin('content','plg_plugin');
// where plg_plugin is your plugin name
$params =& new JParameter( $theplugin ->params ); ////Get default params from plugin

//access default param1 (if availble)
$params->get('param1','default value'); //if parameter param1 is existed,
//it will return a value, else return 'default value'.

 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#2081
support
(Moderator)
Nhóm hỗ trợ
Moderator
Posts: 672
graph
User Offline Click here to see the profile of this user
Gender: Male Luyenkim.NET luyenkimnet Location: Hà Nội Birthdate: 1977-04-07
Re: Re:Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 4 Months, 3 Weeks ago Karma: 3  
Một số hàm hay sử dụng:
Code:

$db =& JFactory::getDBO(); //Ket noi CSDL
$user =& JFactory::getUser(); //Thong tin user
$option = JRequest::getCmd('option'); //Chi xuat hien voi com_content
$view = JRequest::getCmd('view'); //Chi xuat hien voi view = article
$plugin_enabled = $this->params->get('enabled','1');

$config =& JFactory::getConfig();
$offset = $config->getValue('config.offset');
 
Report to moderator   Logged Logged  
 
  The administrator has disabled public write access.
#2113
gmail
(User)
Gold Boarder
Posts: 265
graphgraph
User Offline Click here to see the profile of this user
Birthdate: 1971-01-01
Re: Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 4 Months, 2 Weeks ago Karma: 1  
Cuốn ebook không thể thiếu dành cho nhà phát triển extension của Joomla 1.5
Mastering Joomla! 1.5 Extension and Framework Development
Code:

Table of Contents
Back to BOOK PAGE
Table of Contents
Preface
Chapter 1: Introduction to Joomla!
Chapter 2: Getting Started
Chapter 3: The Database
Chapter 4: Component Design
Chapter 5: Module Design
Chapter 6: Plugin Design
Chapter 7: Extension Design
Chapter 8: Rendering Output
Chapter 9: Customizing the Page
Chapter 10: APIs and Web Services
Chapter 11: Error Handling and Security
Chapter 12: Utilities and Useful Classes
Appendix
Index


Chi tiết xem tại: http://www.packtpub.com/article/joo...amework-table-of-contents

 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#2171
gmail
(User)
Gold Boarder
Posts: 265
graphgraph
User Offline Click here to see the profile of this user
Birthdate: 1971-01-01
Re: Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 4 Months, 1 Week ago Karma: 1  
Mambots/Plugins events - Eventchart all available triggers for Joomla, Mambo and Joomla 1.5:
http://softmarket.ro/joomla-tips/ma...omla-mambo-and-jooml.html

Bảng này rất tiện để các tham khảo về sự kiện đối với mambot/plugins.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#2232
hunting
(User)
Expert Boarder
Posts: 117
graphgraph
User Offline Click here to see the profile of this user
Re: Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 4 Months ago Karma: 2  
mosimagesresize:
http://extensions.joomla.org/compon...k/link_id,5116/Itemid,35/

Chuyển mambot này sang plugin cho J 1.5!
File Attachment:
Please login to download the file!
File Size: 2459
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#2349
gmail
(User)
Gold Boarder
Posts: 265
graphgraph
User Offline Click here to see the profile of this user
Birthdate: 1971-01-01
Re: Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 3 Months, 2 Weeks ago Karma: 1  
File Attachment:
Please login to download the file!
File Size: 4120


Chức năng ẩn Text, khi click chuột lên link sẽ hiện nội dung. Khá thú vị.

Học đuợc gì ở plugin này: đó là hành vi khi có chức năng in PDF "do_pdf",...

Ứng dụng:
  • Làm FAQs - hay mục lục hỏi đáp.
  • ???
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#2384
gmail
(User)
Gold Boarder
Posts: 265
graphgraph
User Offline Click here to see the profile of this user
Birthdate: 1971-01-01
Trả lời: Re: Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 3 Months, 2 Weeks ago Karma: 1  
TnR Events Mailer

http://extensions.joomla.org/compon...k/link_id,5277/Itemid,35/

File Attachment:
Please login to download the file!
File Size: 58657
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#2400
gmail
(User)
Gold Boarder
Posts: 265
graphgraph
User Offline Click here to see the profile of this user
Birthdate: 1971-01-01
Re: Lập trình trong Joomla 1.5.x - sự đơn giản từ khái niệm 3 Months, 1 Week ago Karma: 1  
AContact Manager:

http://extensions.joomla.org/compon...k/link_id,5294/Itemid,35/

File Attachment:
Please login to download the file!
File Size: 337688
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply