iWebShop secondary development, create your own controller, model, view

WBOY
Release: 2016-07-23 08:54:45
Original
1093 people have browsed it
Create controller

Path:/controllers/demo.php

  1. class Demo extends IController
  2. {
  3. public $layout = 'site';
  4. function init()
  5. {
  6. CheckRights::checkUserRights();
  7. }
  8. / **
  9. *Default index method
  10. */
  11. public function index()
  12. {
  13. // Call Model
  14. // Demo_Class::show();
  15. // Get Admin table list information
  16. $adminRow = Demo_Class::adminList();
  17. // Get Admin form information
  18. $adminInfo = Demo_Class::adminInfo();
  19. // Error jump
  20. // IError::show(404,'Payment interface class not found');
  21. // Jump to template
  22. $this->redirect('index');
  23. }
  24. /**
  25. * Test method controller
  26. */
  27. public function demo_list()
  28. {
  29. echo 'demo';
  30. exit;
  31. }
  32. }
Copy code
Title text

Path: /classes/demo_class.php

  1. class Demo_Class
  2. {
  3. /**
  4. * Get data table information output
  5. */
  6. public function adminList()
  7. {
  8. // Get the user table list
  9. $adminObj = new IModel(' user');
  10. $adminRow = $adminObj->query();
  11. return $adminRow;
  12. }
  13. /**
  14. * Get data table information output
  15. */
  16. public function adminInfo()
  17. {
  18. // Get admin table user List
  19. $adminObj = new IModel('admin');
  20. $adminRow = $adminObj->getObj('admin_name = "admin"');
  21. return $adminRow;
  22. }
  23. /**
  24. *Normal output
  25. * /
  26. public static function show()
  27. {
  28. echo 'Who am I';
  29. }
  30. }
Copy code
Create view

Path:/views/default/demo/index.html

  1. Output ordinary model: {echo:Demo_Class::show();}


  2. Output array: {set:$arrInfo = Demo_Class::adminInfo(); echo $arrInfo['last_ip' ];}


  3. {foreach:items = Demo_Class::adminList()}
  4. {$item[' username']}
  5. {/foreach}
Copy code
My own, iWebShop


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template