understanding the structure of joomla
這個很棒喔 ~
http://downloads.joomlacode.org/frsrelease/3/6/7/36751/understanding_the_structure_of_joomla.1.0.pdf
2010-02-01
2010-01-29
Joomla 筆記 (個人紀錄)
// 取得目前所選用的 Template 路徑
$app =& JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();
// Joomla Document Object
$doc =& JFactory::getDocument();
// 引用 Css File
$doc->addStyleSheet($templateDir . "/css/mycssfile.css");
// 引用 JavaScript File
$doc->addScript($templateDir . "/js/myJavaScript.js");
// 引用 Joomla DBO 物件
$db =& JFactory::getDBO();
// 查詢 Content Table 資料表
$stmt = "SELECT * FROM " . $db->getPrefix() . "content";
$db->setQuery($stmt, 0);
// 顯示查詢內容
if ($rows = $db->loadObjectList()) {
foreach ($rows as $row) {
printf("%s", $row->title);
printf("%s", $row->alias);
printf("%s", $row->introtext);
}
}
由於 Joomla 預設是採用 mootools, 若你想使用其他 JavaScript 套件,
可以透過下面的程式碼來移除 mootools
// remove mootools.js and caption.js
$headerstuff = $this->getHeadData();
reset($headerstuff['scripts']);
foreach($headerstuff['scripts'] as $key=>$value){
unset($headerstuff['scripts'][$key]);
}
$this->setHeadData($headerstuff);
$app =& JFactory::getApplication();
$templateDir = JURI::base() . 'templates/' . $app->getTemplate();
// Joomla Document Object
$doc =& JFactory::getDocument();
// 引用 Css File
$doc->addStyleSheet($templateDir . "/css/mycssfile.css");
// 引用 JavaScript File
$doc->addScript($templateDir . "/js/myJavaScript.js");
備註 : 可以使用 CDN 的方式來引用 JavaScript & Css File.
$templateDir 是目前使用中的樣板路徑
$templateDir 是目前使用中的樣板路徑
// 引用 Joomla DBO 物件
$db =& JFactory::getDBO();
// 查詢 Content Table 資料表
$stmt = "SELECT * FROM " . $db->getPrefix() . "content";
$db->setQuery($stmt, 0);
// 顯示查詢內容
if ($rows = $db->loadObjectList()) {
foreach ($rows as $row) {
printf("%s", $row->title);
printf("%s", $row->alias);
printf("%s", $row->introtext);
}
}
由於 Joomla 預設是採用 mootools, 若你想使用其他 JavaScript 套件,
可以透過下面的程式碼來移除 mootools
// remove mootools.js and caption.js
$headerstuff = $this->getHeadData();
reset($headerstuff['scripts']);
foreach($headerstuff['scripts'] as $key=>$value){
unset($headerstuff['scripts'][$key]);
}
$this->setHeadData($headerstuff);
2010-01-27
PHP Object Basics
- Class and objects: Declaring classes, instantiating objects
- Constructor methods: Automating the setup of your objects
- Primitive and class types: Why type matters
- Inheritance: Why we need inheritance, and how to use it
- Visibility: Streamlining your object interfaces and protecting your methods and properties from meddling
- 類別與物件 : 如何宣告類別, 實例化物件
- 建構式方法 : 初始化物件
- 原型類別 : 建構原型需要留意哪些事項
- 繼承 : 為何需要繼承, 我該如何使用它
- 可視性 : 物件的特性與介面透過封裝來保護物件與物件之間的溝通
2010-01-26
利用 StarUML 產生一個簡易的PHP類別
StarUML 現在可以利用 template 產生 PHP 程式碼, 也就是說, 我們可以透過類別圖定義來產生 PHP 的程式碼, 下面將說明如何產生一個簡易的 Class ShopProduct
- starUML 下載 http://staruml.sourceforge.net/en/download.php
- PHP5 Code Generator Template http://staruml.sourceforge.net/en/templates.php
下載好後, 請先安裝 starUML, 安裝好後將 PHP5 code Generator Template 解壓縮,
並放入到 C:\Program Files\StarUML\modules\staruml-generator\templates 目錄下
(小提示)
安裝目錄不一樣請將 PHP5 code Generator Template
放入到 StarUML\modules\staruml-generator\templates 目錄下
放入到 StarUML\modules\staruml-generator\templates 目錄下
1. 接下來啟動 starUML
2. 選擇 Empty Project
3. Model Explorer 右鍵新增一個 model, 並命名為 PHP Generator Code
4. 在 PHP Generator Code 中右鍵 Add Diagram, 我們選 Class Diagram,
並給這張圖一個名稱, ShopProduct
5. 點選 Class 確定它是被選取狀態, 並在ShopProduct Class Diagram 中空白處在點選一次,
這時你就會看見一個 Class Diagram, 我們將它名命 ShopProduct
6. 新增 ShopProduct Properties , 我們設定了 Title, producerMainName, producerFirstName, price
7. 新增二個 Method, 分別 __construct(), getProducer()
8. 按下 F9 會出現驗證對話方塊, 驗證一下畫的圖對不對
9. 選單 Tools -> StarUML Generator...
10. Select templates for generator 選 PHP 5 code Generator
這樣 starUML 就會幫你產生 PHP 程式碼, 在 starUML 中定義的 shopProduct
訂閱:
文章 (Atom)