zoukankan      html  css  js  c++  java
  • html模板代码如何写进数据库,以及fastadmin如何,读取html代码,并替换

    html模板代码如何写进数据库?

    先做一个表单,
    提交两个字段:
    1.表单名字
    2.编辑(编辑器使用fastadmin的编辑器插件)
    提交到哪个位置呢?
    提交到自定义表单里吧。
    也就是说,模板是字符串了。

    那么fastadmin如何读取模板,并替换变量呢?

    请求地址:
    http://ceshi.com/admin.php/formdesign/Form/tempview?layout=&form_id=5&design_content=''

    具体方法
    js控制预览操作

     //新增控件事件
                    Controller.api.addPlugins();
                    $('#button_review').on('click', function() {
                        Controller.api.genSource();
                        var form_id = $('#form_id').val();
                        var content = $('#source').val();
                        var layout = $('#layout').val();
                        if (content.length > 1) {
                            Fast.api.open(
                                'formdesign/Form/tempview?layout=' + layout + '&form_id=' + form_id + '&design_content=' + encodeURIComponent(content),
                                '预览', {}
                            );
                        } else {
                            Toastr.warning('表单内容不能为空!');
                            return false;
                        }
                    });
    

    php处理

    /**
         * 临时预览页面
         */
        public function tempview()
        {
            $form_id = $this->request->param('form_id');
            $layout = $this->request->param('layout');
            $form = $this->model->get($form_id);
            $temp['content'] = $this->request->param('design_content');
            if ($temp !== '' or $temp !== ' ') {
                $formdesign = new Formdesign();
                $design_content = $formdesign->unparse_form($temp, [], 'preview');
                $this->assign('design_content', $design_content);
                $this->assign('layout', $layout);
                $this->view->engine->layout('layout/default');
            } else {
                $this->error('表单不能为空!');
            }
            return $this->view->fetch();
        }
        /**
         * 表单预览页面
         */
        public function preview()
        {
            $form_id = $this->request->param('ids');
            if ($form_id <= 0) {
                $this->error('参数有误,请返回重试!');
            }
            $map = array(
                'id' => $form_id,
                'status' => 'normal',
            );
            $form = $this->model->where($map)->find();
    
            if (!$form) {
                $this->error('未找到表单数据,请返回重试!');
            }
    
            $formdesign = new Formdesign();
            $form['content'] = $formdesign->unparse_form($form, array(), 'preview');
    
            $this->assign('one', $form);
            $this->view->engine->layout('layout/default');
            return $this->view->fetch();
        }
    
  • 相关阅读:
    开发者看过来,哪个移动平台好赚钱?
    EGit下配置Github项目
    用户接口(UI)设计的 20 条原则
    要想工作效率高,我们到底需要多少睡眠?
    Android 读取<metadata>元素的数据
    Android实现推送方式解决方案
    余晟:做个懂产品的程序员
    Gson简要使用笔记
    编程从业五年的十四条经验,句句朴实
    程序员不是包身工
  • 原文地址:https://www.cnblogs.com/cn-oldboy/p/13789799.html
Copyright © 2011-2022 走看看