Seo.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. * ============================================================================
  14. * 控制器
  15. */
  16. class Seo extends AdminControl {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/seo.lang.php');
  20. }
  21. function index() {
  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. }