微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Prestashop 1.7 - 在文件上传时显示自定义成功消息

如何解决Prestashop 1.7 - 在文件上传时显示自定义成功消息

我正在 Prestashop 上开发我的第一个模块,该模块包括从 xlsx 文件创建产品。

我能够在上传方法显示自定义错误消息,但无法显示成功消息。

波纹管代码有效,我收到一条自定义错误消息:

 if (file_exists($this->uploadDirectory.DIRECTORY_SEParaTOR.$_FILES["file"]['name'])) {
            $this->context->smarty->assign('error','O ficheiro já existe!');
            $this->uploadError = true;
            return false;
   }

下面的代码有效,但我没有收到任何成功消息:

if (!$this->uploadError) {
            if (move_uploaded_file($_FILES["file"]["tmp_name"],$this->uploadDirectory. $_FILES["file"]["name"])) {
                $this->context->smarty->assign('success',"O ficheiro " . $file['name'] . " foi gravado com sucesso.");
                return true;
            }
        }

getContent 函数代码

/**
     * Load the configuration form
     */
    public function getContent()
    {
        /**
         * If values have been submitted in the form,process.
         */
        if (((bool)Tools::isSubmit('submitExpodirectModule')) == true) {
            $this->postProcess();
        }

        $this->context->smarty->assign('module_dir',$this->_path);

        $output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/configure.tpl');

        $outputEnd= $this->context->smarty->fetch($this->local_path.'views/templates/admin/table.tpl');


        return $output.$this->renderForm().$outputEnd;
    }

解决方法

上传成功后在 getContent 中使用它并将其添加到输出中

$success_message = $this->displayConfirmation($this->l('消息显示在那里。'));

返回 $success_message.form 内容和其他输出

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。