バージョン選択

フォーラム

メニュー

オンライン状況

73 人のユーザが現在オンラインです。 (63 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 73
もっと...

サイト内検索

機能要望 > フロント機能 > 注文時にファイル添付をできるようにしたい

フロント機能

新規スレッドを追加する

スレッド表示 | 新しいものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
mizuvan
投稿日時: 2015/1/28 15:15
対応状況: −−−
長老
登録日: 2013/3/26
居住地:
投稿: 253
注文時にファイル添付をできるようにしたい
http://al-lucky.hatenablog.com/entry/2014/09/17/133220

上記サイトを参考にファイル添付機能を加えようと思っています。

ただ、あまり意味がわからないまま一通り作業を施したところ
エラーとなり、phpソースを観てみると 「・・・」となっていたのでその部分を空白にしたところページにはまったく表示されず・・・
ヘッダーとサイドバー、フッターのみの表示となりました。

このサイトのはじめの部分がわからなかったのですが

それが下記の部分です。

引用:
今回は、管理画面の「デザイン設定>ページ詳細設定」からuser_data配下に新規ページ「/attach_mail」を作成し、そこにフォームを設置しています。
/user_data/attach_mail.phpにクラス( LC_Page_User_xxx )が自動生成されているので、それをカスタマイズします。


LC_Page_User_xxxが自動生成とありますが、どこに自動生成されるのでしょうか?
data/class内、data/class_extends内に見当たりませんでした。

見落としているのかもしれませんが、2回ほど見たつもりです。

どなたかアドバイスいただけますでしょうか


----------------

yuh
投稿日時: 2015/1/28 15:55
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1818
Re: 注文時にファイル添付をできるようにしたい
html/user_data/attach_mail.phpのファイルを開いたら。
LC_Page_User_attach_mailというクラスがあると思います。
mizuvan
投稿日時: 2015/1/31 11:38
対応状況: −−−
長老
登録日: 2013/3/26
居住地:
投稿: 253
Re: 注文時にファイル添付をできるようにしたい
yuh様、いつもありがとうございます。

デザイン管理>PC>ページ詳細設定 より 新規ページを

attach_mail.php として作成しましたが

その中身は下記の通りでした・・
やり方が間違っているのでしょうか?


<?php
require_once '../require.php';
require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
 * ユーザーカスタマイズ用のページクラス
 *
 * 管理画面から自動生成される
 *
 * @package Page
 */
class LC_Page_User extends LC_Page_Ex
{
    /**
     * Page を初期化する.
     *
     * @return void
     */
    function init()
    {
        parent::init();
    }

    /**
     * Page のプロセス.
     *
     * @return void
     */
    function process()
    {
        parent::process();
        $this->action();
        $this->sendResponse();
    }

    /**
     * Page のアクション.
     *
     * @return void
     */
    function action()
    {
    }
}

$objPage = new LC_Page_User();
$objPage->init();
$objPage->process();


----------------

yuh
投稿日時: 2015/1/31 12:08
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1818
Re: 注文時にファイル添付をできるようにしたい
そのファイルの function action()
の部分とかに色々サイトに乗っているやつを追加していってください。
テンプレートはSmarty/templates/default/user_data/attach_mail.tpl
等にできているはずです。
mizuvan
投稿日時: 2015/1/31 12:47
対応状況: −−−
長老
登録日: 2013/3/26
居住地:
投稿: 253
Re: 注文時にファイル添付をできるようにしたい
yuh様さっそくありがとございます。

LC_Page_User_xxx となっていない点は問題なさそうですね?

function action()へざっとコピペしてみたのですが
それが真っ白になってしまうのです。

ざっと見て頂いて何か変なところはわかりますでしょうか?


<?php
require_once '../require.php';
require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
 * ユーザーカスタマイズ用のページクラス
 *
 * 管理画面から自動生成される
 *
 * @package Page
 */
class LC_Page_User extends LC_Page_Ex
{
    /**
     * Page を初期化する.
     *
     * @return void
     */
    function init()
    {
        parent::init();
    }

    /**
     * Page のプロセス.
     *
     * @return void
     */
    function process()
    {
        parent::process();
        $this->action();
        $this->sendResponse();
    }

    /**
     * Page のアクション.
     *
     * @return void
     */
    function action()
    {
        $objFormParam = new SC_FormParam_Ex();

        $this->arrData = isset($_SESSION['customer']) ? $_SESSION['customer'] : '';

        // アップロードファイル情報の初期化
        $objUpFile = new SC_UploadFile_Ex(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
        $this->lfInitFile($objUpFile);
        $objUpFile->setHiddenFileList($_POST);

        $mode = $this->getMode();
        switch ($mode) {
            case 'confirm':
                // エラーチェック
                $this->lfInitParam($objFormParam);
                $objFormParam->setParam($_POST);
                $objFormParam->convParam();
                $objFormParam->toLower('email');
                $objFormParam->toLower('email02');
                $this->arrErr = $this->lfCheckError($objFormParam);
                // 入力値の取得
                $this->arrForm = $objFormParam->getFormParamList();

                if (SC_Utils_Ex::isBlank($this->arrErr)) {
                    // エラー無しで完了画面
                    $this->tpl_mainpage = 'user_data/attach_mail_confirm.tpl';
                    $this->tpl_title = '添付ファイルメール(確認ページ)';
                }

                break;

            case 'return':
                $this->lfInitParam($objFormParam);
                $objFormParam->setParam($_POST);
                $this->arrForm = $objFormParam->getFormParamList();

                break;

            case 'complete':
                $this->lfInitParam($objFormParam);
                $objFormParam->setParam($_POST);
                $this->arrErr = $objFormParam->checkError();
                $this->arrForm = $objFormParam->getFormParamList();
                if (SC_Utils_Ex::isBlank($this->arrErr)) {
                    $this->lfSendMail($this);

                    // 完了ページへ移動する
                    SC_Response_Ex::sendRedirect('complete.php');
                    SC_Response_Ex::actionExit();
                } else {
                    SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
                    SC_Response_Ex::actionExit();
                }
                break;

            // 画像のアップロード
            case 'upload_image':
            case 'delete_image':
                // パラメーター初期化
                $this->lfInitParam($objFormParam);
                $objFormParam->setParam($_POST);
                $this->arrErr = $objFormParam->checkError();
                $this->arrForm = $objFormParam->getFormParamList();

                switch ($mode) {
                    case 'upload_image':
                        // ファイルを一時ディレクトリにアップロード
                        $this->arrErr[$this->arrForm['image_key']['value']] = $objUpFile->makeTempFile($this->arrForm['image_key']['value'], IMAGE_RENAME);
                        if ($this->arrErr[$this->arrForm['image_key']['value']] == '') {
                            $img_temp_fullname = $objUpFile->temp_dir.'/'.$objUpFile->temp_file;
                        }
                        break;
                    case 'delete_image':
                        // ファイル削除
                        $this->lfDeleteTempFile($objUpFile, $this->arrForm['image_key']['value']);
                        break;
                    default:
                        break;
                }

                // 入力画面表示設定
                // アップロードファイル情報取得(Hidden用)
                $this->arrHidden = $objUpFile->getHiddenFileList();
                // 画像ファイル表示用データ取得
                $this->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH);
                break;

            default:

                break;
        }
    }
    public function lfInitParam(&$objFormParam)
    {
        $objFormParam->addParam('テキスト入力', 'some_input', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
        $objFormParam->addParam('sample_image', 'sample_image', '', '', array());
        $objFormParam->addParam('image_key', 'image_key', '', '', array());
        $objFormParam->addParam('sample_image_realpath', 'sample_image_realpath', '', '', array());
        $objFormParam->addParam('sample_image_urlpath', 'sample_image_urlpath', '', '', array());
    }
    public function lfInitFile(&$objUpFile)
    {
        $objUpFile->addFile('画像', 'sample_image', array('jpg', 'gif', 'png'), IMAGE_SIZE, false, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
    }
    public function lfDeleteTempFile(&$objUpFile, $image_key)
    {
        $arrTempFile = $objUpFile->temp_file;
        $arrKeyName = $objUpFile->keyname;

        foreach ($arrKeyName as $key => $keyname) {
            if ($keyname != $image_key) continue;

            if (!empty($arrTempFile[$key])) {
                $temp_file = $arrTempFile[$key];
                $arrTempFile[$key] = '';

                if (!in_array($temp_file, $arrTempFile)) {
                    $objUpFile->deleteFile($image_key);
                } else {
                    $objUpFile->temp_file[$key] = '';
                    $objUpFile->save_file[$key] = '';
                }
            } else {
                $objUpFile->temp_file[$key] = '';
                $objUpFile->save_file[$key] = '';
            }
        }
    }
    public function lfCheckError(&$objFormParam)
    {
        // 入力データを渡す。
        $arrForm =  $objFormParam->getHashArray();
        $objErr = new SC_CheckError_Ex($arrForm);
        $objErr->arrErr = $objFormParam->checkError();
        $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', 'email', 'email02') ,array('EQUAL_CHECK'));

        return $objErr->arrErr;
    }
    public function lfSendMail(&$objPage)
    {
        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
        $objPage->tpl_shopname = $CONF['shop_name'];
        $objPage->tpl_infoemail = $CONF['email02'];
        $attachment = $objPage->arrForm['sample_image_realpath']['value'];
        $helperMail = new SC_Helper_Mail_Ex();
        $helperMail->setPage($this);
        $helperMail->sfSendTemplateMail(
            $objPage->arrForm['email']['value'],            // to
            $objPage->arrForm['name01']['value'] .' 様',    // to_name
            6,                                              // template_id
            $objPage,                                       // objPage
            $CONF['email03'],                               // from_address
            $CONF['shop_name'],                             // from_name
            $CONF['email02'],                               // reply_to
            $CONF['email02'],                               // bcc
            $attachment                                     // attachment
        );
    }
}

$objPage = new LC_Page_User();
$objPage->init();
$objPage->process();


----------------

yuh
投稿日時: 2015/1/31 12:56
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1818
Re: 注文時にファイル添付をできるようにしたい
エラーログをお願いします。
あと、テンプレートのほうは調整しましたか?
mizuvan
投稿日時: 2015/1/31 13:17
対応状況: −−−
長老
登録日: 2013/3/26
居住地:
投稿: 253
Re: 注文時にファイル添付をできるようにしたい
yuh様、何度もありがとうございます

大変失礼いたしました。テンプレートファイルは作っていませんでした・・・

さっそく作りましたが、下記のようなエラーでした。

きっと、意味がしっかりわからずPHPをコピーして作っただけのものでしたのでめちゃくちゃなのでしょうか

引用:
2015/01/31 13:13:33 [/***/user_data/attach_mail.php] Fatal error(E_USER_ERROR): Smarty error: [in ***/data/Smarty/templates/original/user_data/attach_mail.tpl line 171]: syntax error: unclosed tag \{else} (opened line 160). (Smarty_Compiler.class.php, line 317) on [***/data/module/Smarty/libs/Smarty.class.php(1094)] from IPアドレス
customer_id = 1
***/user_data/attach_mail.php(204): LC_Page_User->process
***/user_data/attach_mail.php(33): LC_Page->sendResponse
***/data/class/pages/LC_Page.php(152): SC_Display->prepare
***/data/class/SC_Display.php(80): SC_View->getResponse
***/data/class/SC_View.php(101): Smarty->fetch
***/data/module/Smarty/libs/Smarty.class.php(1264): include
***/data/Smarty/templates_c/original/%%F1^F15^F158E3F4%%site_frame.tpl.php(177): Smarty->_smarty_include
***/data/module/Smarty/libs/Smarty.class.php(1870): include
***/data/Smarty/templates_c/original/%%58^587^5876E692%%site_main.tpl.php(39): Smarty->_smarty_include
***/data/module/Smarty/libs/Smarty.class.php(1868): Smarty->_compile_resource
***/data/module/Smarty/libs/Smarty.class.php(1423): Smarty->_compile_source
***/data/module/Smarty/libs/Smarty.class.php(1490): Smarty_Compiler->_compile_file
***/data/module/Smarty/libs/Smarty_Compiler.class.php(317): Smarty_Compiler->_syntax_error
***/data/module/Smarty/libs/Smarty_Compiler.class.php(2256): Smarty->_trigger_fatal_error
***/data/module/Smarty/libs/Smarty.class.php(1816): Smarty->trigger_error
***/data/module/Smarty/libs/Smarty.class.php(1094): trigger_error


----------------

yuh
投稿日時: 2015/1/31 13:25
対応状況: −−−
登録日: 2013/1/9
居住地: 大阪
投稿: 1818
Re: 注文時にファイル添付をできるようにしたい
テンプレートの記載が間違えてるっぽいですね。
<!--{if}-->に対しての閉じる<!--{/if}-->とからへんでエラーが起こってます。
mizuvan
投稿日時: 2015/1/31 15:06
対応状況: −−−
長老
登録日: 2013/3/26
居住地:
投稿: 253
Re: 注文時にファイル添付をできるようにしたい
yuh様ありがとうございます!

最後に<!--{/if}-->が抜けていました・・
しかも、文字コードもUTF-8Nにしてなくて修正後
問題なく表示できました

さらに下記ファイルをカスタマイズ
SC_Helper_Mail.php
SC_SendMail.php

しかし、送信ができないのです・・

項目を入力、添付ファイルも選んだ後に送信をしてもページは変わらず入力した内容が消え、添付ファイルの選択も消えてしまう状態です。

エラーログには何も残っていません

どこかしらで新たなconfirm.tplの設定をしなければならないのでしょか?


----------------

mizuvan
投稿日時: 2015/2/3 18:31
対応状況: −−−
長老
登録日: 2013/3/26
居住地:
投稿: 253
Re: 注文時にファイル添付をできるようにしたい
その後、入力内容が表示されていなかったのは

IfInitParam()に流用元の内容を書いていませんでした為、表示が消えてしまったようでした。
再度、追記したところ入力した内容なども消えません

ただ、添付ファイルの内容は消えてしまっています。IfInitFile()で指定したファイル形式とサイズ内なら大丈夫だと思っていましたが

あとは添付ファイル無しの場合でも入力確認画面に遷移しませんでした。

参考にしたページに書かれていた通りにしたはずなのですが・・
    /**
     * フォームの入力内容をチェックします。
     *
     */

    public function lfCheckError(&$objFormParam)
    {
        // 入力データを渡す。
        $arrForm =  $objFormParam->getHashArray();
        $objErr = new SC_CheckError_Ex($arrForm);
        $objErr->arrErr = $objFormParam->checkError();
        $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', 'email', 'email02') ,array('EQUAL_CHECK'));

        return $objErr->arrErr;
    }
    /**
     * メール送信処理。
     *
     */

		
    public function lfSendMail(&$objPage)
    {
        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
        $objPage->tpl_shopname = $CONF['shop_name'];
        $objPage->tpl_infoemail = $CONF['email02'];
        $attachment = $objPage->arrForm['sample_image_realpath']['value'];
        $helperMail = new SC_Helper_Mail_Ex();
        $helperMail->setPage($this);
        $helperMail->sfSendTemplateMail(
            $objPage->arrForm['email']['value'],            // to
            $objPage->arrForm['name01']['value'] .' 様',    // to_name
            6,                                              // template_id
            $objPage,                                       // objPage
            $CONF['email03'],                               // from_address
            $CONF['shop_name'],                             // from_name
            $CONF['email02'],                               // reply_to
            $CONF['email02'],                               // bcc
            $attachment                                     // attachment
        );
    }



さらに迷った点が attach_mail.tpl はどの部分のことをいっているかという点なのですが・・

data/Smarty/templates/default/mail_templates/attach_mail.tpl
data/Smarty/templates/default/user_data/attach_mail.tpl



----------------

(1) 2 »
スレッド表示 | 新しいものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,301名です
総投稿数は109,692件です

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1568
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.