ホームページ  >  記事  >  バックエンド開発  >  iWebShop の二次開発、独自のコントローラー、モデル、ビューの作成

iWebShop の二次開発、独自のコントローラー、モデル、ビューの作成

WBOY
WBOYオリジナル
2016-07-23 08:54:451054ブラウズ
コントローラーの作成

パス:/controllers/demo.php

  1. class Demo extends IController
  2. {
  3. public $layout = 'site';
  4. function init()
  5. {
  6. CheckRights::checkUserRights();
  7. }
  8. / **
  9. *デフォルトのインデックス方法
  10. */
  11. public functionindex()
  12. {
  13. // Model を呼び出す
  14. // Demo_Class::show();
  15. // 管理テーブルのリスト情報を取得
  16. $adminRow = Demo_Class::adminList();
  17. // 管理フォーム情報を取得します
  18. $adminInfo = Demo_Class::adminInfo();
  19. // エラージャンプ
  20. // IError::show(404,'Payment Interface class not found');
  21. // にジャンプしますtemplate
  22. $this->redirect('index');
  23. }
  24. /**
  25. * テストメソッドコントローラー
  26. */
  27. public function Demon_list()
  28. {
  29. echo 'demo';
  30. exit;
  31. }
  32. }
コードをコピー
タイトルテキスト

パス: /classes/demo_class.php

  1. class Demo_Class
  2. {
  3. /**
  4. * データテーブル情報の出力を取得します
  5. */
  6. public function adminList()
  7. {
  8. // ユーザーテーブルリストを取得します
  9. $adminObj = new IModel( ' user');
  10. $adminRow = $adminObj->query();
  11. return $adminRow;
  12. }
  13. /**
  14. * データテーブル情報の出力を取得します
  15. */
  16. public function adminInfo()
  17. {
  18. // 管理テーブルを取得ユーザーリスト
  19. $adminObj = new IModel('admin');
  20. $adminRow = $adminObj->getObj('admin_name = "admin"');
  21. return $adminRow;
  22. }
  23. /**
  24. *通常出力
  25. * /
  26. public static function show()
  27. {
  28. echo 'Who am I';
  29. }
  30. }
コードをコピー
ビューを作成

パス:/views/default/demo/index.html

  1. 通常のモデルを出力: {echo:Demo_Class::show();}
  2. < ;!-- データ フォームの詳細データを出力します-->


  3. 出力配列: {set:$arrInfo = Demo_Class::adminInfo(); echo $arrInfo['last_ip ' ];}


  4. {foreach:items = Demo_Class::adminList()}
  5. {$item[ ' ユーザー名']}
  6. {/foreach}
コードをコピー
私自身の iWebShop


声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。