Seo.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. use think\facade\Db;
  6. /**
  7. *
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * 控制器
  12. */
  13. class Seo extends AdminControl
  14. {
  15. public function initialize()
  16. {
  17. parent::initialize();
  18. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/seo.lang.php');
  19. }
  20. function index()
  21. {
  22. if (!request()->isPost()) {
  23. //读取SEO信息
  24. $list = Db::name('seo')->select()->toArray();
  25. $seo = array();
  26. foreach ((array) $list as $value) {
  27. $seo[$value['seo_type']] = $value;
  28. }
  29. View::assign('seo', $seo);
  30. // $category = model('goodsclass')->getGoodsclassForCacheModel();
  31. // View::assign('category', $category);
  32. return View::fetch('index');
  33. } else {
  34. $update = array();
  35. $seo = input('post.SEO/a'); #获取数组
  36. if (is_array($seo)) {
  37. foreach ($seo as $key => $value) {
  38. Db::name('seo')->where(array('seo_type' => $key))->update($value);
  39. }
  40. dkcache('seo');
  41. ds_json_encode('10000', lang('ds_common_save_succ'));
  42. }
  43. }
  44. }
  45. }