Seo.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  11. * 网站地址: https://www.valimart.net/
  12. * ----------------------------------------------------------------------------
  13. *
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Seo extends AdminControl {
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'admin/lang/'.config('lang.default_lang').'/seo.lang.php');
  21. }
  22. function index() {
  23. if (!request()->isPost()) {
  24. //读取SEO信息
  25. $list = Db::name('seo')->select()->toArray();
  26. $seo = array();
  27. foreach ((array) $list as $value) {
  28. $seo[$value['seo_type']] = $value;
  29. }
  30. View::assign('seo', $seo);
  31. // $category = model('goodsclass')->getGoodsclassForCacheModel();
  32. // View::assign('category', $category);
  33. return View::fetch('index');
  34. } else {
  35. $update = array();
  36. $seo = input('post.SEO/a');#获取数组
  37. if (is_array($seo)) {
  38. foreach ($seo as $key => $value) {
  39. Db::name('seo')->where(array('seo_type' => $key))->update($value);
  40. }
  41. dkcache('seo');
  42. ds_json_encode('10000', lang('ds_common_save_succ'));
  43. }
  44. }
  45. }
  46. }
  47. ?>