عزيزي المبرمج فلنبدا الان بالخطوة الاولى و هي اظافة صفحة جديدة للمتجر
حتى نوضح كيف تعمل AMHSOFT FrameWork
ملاحظة: يمكن للمستخدم اضافة صفحة جديدة من خلال لوحة التحكم لكنها
صفحة ثابتة اي بمعنى اخر لو اردنا انشاء صفحة ديناميكية لا بد من اضافتها
برمجيا مثال لذلك صفحة تعرض لنا عدد المنتجات
الخطوة الاولى: اضافة صفحة PHP جديدة تسمى على سبيل المثال itemscount.class.php
تحت ملف pages
ملاحظة: لابد ان يكون ملحق الصفحة class.php.
المحتوى:
| 1 |
/*my first page*/
|
| 2 |
php
|
| 3 |
/*the class name
must be like the page name*/
|
| 4 |
/*the difference is
described below:*/
|
| 5 |
/*the first letter
of the class name must be: "c"*/
|
| 6 |
/*and the first
letter of the page name must be upper case*/
|
| 7 |
/*for example: if
the page name is "items.class.php",*/
|
| 8 |
/*then the class
name must be "cItems"*/
|
| 9 |
|
| 10 |
/*In the MVC-Model
the class Page represents the model.*/
|
| 11 |
/*this class extends
Page*/
|
| 12 |
class cItemscount extends Page{
|
| 13 |
function __default()
|
| 14 |
{
|
| 15 |
$count = 0; /*initialize my variable*/
|
| 16 |
$count = $this->connection->getCount("SELECT * FROM products");
|
| 17 |
/*$this->connection:
is a library included in */
|
| 18 |
/*the
AMHSOFT Framework,*/
|
| 19 |
/*that
permits to handle mysql commands*/
|
| 20 |
$this->template->assign("count_of_products", $count);
|
| 21 |
$this->show()
|
| 22 |
}
|
| 23 |
?>
|
الخطوة الثانية: اضافة صفحة HTML جديدة تسمى itemscount.tpl.html
تحت ملف views
ملاحظة: لابد ان يتوافق اسم الصفحتين و ان يكون ملحق الصفحة tpl.html.
المحتوى:
| 1 |
<h1>Count of products: {$count_of_products}h1>
|
منادات الصفحة يكون كالاتي:
http://www.mysite.com/index.php?page=itemscount
او
http://www.mysql.com/itemscount.html
الدرس الثاني مبني على الدرس الاول
نريد في الدرس الثاني انشاء صحة جديدة نعرض فيها عدد المنتجات المفعلة فقط
AMHSOFT FrameWork توفر لك جهدا كبير سوف تكتشف ذلك بنفسك
في هذه المرة سوف لن نقوم بانشاء صفحة جديدة انما سنعتمد على الصفحة
القديمة و ذلك باضافة فقط function
| 1 |
/*my first page*/
|
| 2 |
php
|
| 3 |
/*the class name
must be like the page name*/
|
| 4 |
/*the difference is
described below:*/
|
| 5 |
/*the first letter
of the class name must be: "c"*/
|
| 6 |
/*and the first
letter of the page name must be upper case*/
|
| 7 |
/*for example: if
the page name is "items.class.php",*/
|
| 8 |
/*then the class
name must be "cItems"*/
|
| 9 |
|
| 10 |
/*In the MVC-Model
the class Page represents the model.*/
|
| 11 |
/*this class extends
Page*/
|
| 12 |
class cItemscount extends Page{
|
| 13 |
function __default()
|
| 14 |
{
|
| 15 |
$count = 0; /*initialize my variable*/
|
| 16 |
$count = $this->connection->getCount("SELECT * FROM products");
|
| 17 |
/*$this->connection:
is a library included in */
|
| 18 |
/*the
AMHSOFT Framework,*/
|
| 19 |
/*that
permits to handle mysql commands*/
|
| 20 |
$this->template->assign("count_of_products", $count);
|
| 21 |
$this->show()
|
| 22 |
}
|
| 23 |
function __online()
|
| 24 |
{
|
| 25 |
$count = 0; /*initialize my variable*/
|
| 26 |
$count = $this->connection->getCount("SELECT * FROM products WHERE online = 1");
|
| 27 |
$this->template->assign("count_of_products", $count);
|
| 28 |
$this->show()
|
| 29 |
}
|
| 30 |
?>
|
منادات الصفحة يكون كالاتي:
http://www.mysite.com/index.php?page=itemscount&event=online
او
http://www.mysite.com/itemscount-online.html
عزيزي المبرمج في دروس اخرى نقوم بشرح كيفية زيادة وحدة للمتجر و كيفية
زيادة وحدة للوحة التحكم كذلك كيفية تغيير الستايل