独自画面を作成して、メニューからダイアログを使用(CmsType2Test03)

構成

$MT_DIR/
|__ plugins/
|  |__ CmsType2Test03/
|     |__ config.yaml
|     |__ lib/
|     |  |__ CmsType2Test03
|     |      |__ CMS.pm
|     |__ tmpl/
|     |  |__ test1_mode.tmpl
|     |  |__ test1_set_mode.tmpl
 
 
 

ソース

config.yaml

id: CmsType2Test03
key: CmsType2Test03
name: CmsType2Test03
version: 1.00
description: 独自画面のテスト
author_name: CmsType2Test03の作成者
author_link: http://www.example.com/about/
doc_link: http://www.example.com/docs/
 
# アプリケーション
applications:
    # CMS管理画面
    cms:
        # メニュー画面
        menus:
            # カスタムメニュー
            custom_menu:
                # 表示名
                label: Custom Menu
                # 表示順
                order: 1000
            # リストメニューサブ1
            custom_menu:test1:
                # 表示名
                label: test1
                # 表示順
                order: 100
                # 表示スコープ
                view:
                    - website
                    - blog
                # モード
                mode: test1_mode
                # ダイアログ
                dialog: 1
 
        # メソッド定義
        methods:
            # "custom_menu:test1"をクリックした場合に呼び出される
            test1_mode: $CmsType2Test03::CmsType2Test03::CMS::test1_mode
            test1_set_mode: $CmsType2Test03::CmsType2Test03::CMS::test1_set_mode
 
 

lib/CmsType2Test03/CMS.pm

package CmsType2Test03::CMS;
 
use strict;
 
use MT::FileMgr;
use Data::Dumper;
 
use Encode;
use utf8;
 
sub test1_mode{
 
    # パラメータ取得
    my ($app) = @_;
 
    # 返却用パラメータ定義
    my ( %param, %args, %terms );
 
    # パラメータコンテキスト取得
    my $q = $app->param;
 
    # ブログID取得
    my $blog_id = $q->param('blog_id');
 
    $param{save_success} = $q->param('success');
 
    # テンプレートを設定
    $app->load_tmpl('test1_mode.tmpl', \%param );
}
 
sub test1_set_mode{
 
    # パラメータ取得
    my ($app) = @_;
 
    # 返却用パラメータ定義
    my ( %param, %args, %terms );
 
    # パラメータコンテキスト取得
    my $q = $app->param;
 
    # ブログID取得
    my $blog_id = $q->param('blog_id');
 
    # パラメータ取得
    my $test1_name = $q->param('test1_name');
 
    # パラメータ設定
    $param{test1_name} = $test1_name;
    $param{save_success} = $q->param('success');
 
    # テンプレートを設定
    $app->load_tmpl('test1_set_mode.tmpl', \%param );
}
 
sub debug{
 
    my ($data) = @_;
 
    $Data::Dumper::Terse = 1;
    $Data::Dumper::Indent = 1;
    my $dump = Dumper($data);
 
    my $file = "/home/httpd/cgi-bin/mt/aaa.txt";
    my $fmgr = MT::FileMgr->new('Local');
    $fmgr->put_data($dump, $file);
}
 
1;
 
 

tmpl/test1_mode.tmpl

<mt:include name="dialog/header.tmpl" page_title="New Dialog Menu">
 
<form method="post" action="<mt:var name="script_url">">
 
  <input type="hidden" name="__mode" value="test1_set_mode" />
  <input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
  <input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
 
  <fieldset>
    <mtapp:setting
       id="test1-name-field"
       required="1"
       label="<__trans phrase="Test1 Name">"
       show_hint="1"
       hint="<__trans phrase="test1 name">">
      <input type="text" name="test1_name" id="test1_name" class="text required" value="<mt:var name="test1_name" escape="html">" />
    </mtapp:setting>
 
  </fieldset>
 
  <div class="actions-bar">
      <div class="actions-bar-inner pkg actions">
              <button
                  type="submit"
                  class="action button primary primary-button"
                  title="Action"
                  >Action</button>
              <button
                  type="submit"
                  class="action button primary primary-button mt-close-dialog"
                  title="Close"
                  >Close</button>
      </div>
  </div>  
 
</form>
 
<mt:include name="dialog/footer.tmpl">
 
 

tmpl/test1_set_mode.tmpl

<mt:include name="dialog/header.tmpl" page_title="New Dialog Menu">
 
<form method="post" action="<mt:var name="script_url">">
 
  <input type="hidden" name="__mode" value="test1_set" />
  <input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
  <input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
 
  <fieldset>
    <mtapp:setting
       id="test1-name-field"
       required="1"
       label="<__trans phrase="Test1 Name">"
       show_hint="1"
       hint="<__trans phrase="test1 name">">
      <input type="text" name="test1_name" id="test1_name" class="text required" value="<mt:var name="test1_name" escape="html">" readonly />
    </mtapp:setting>
 
  </fieldset>
 
  <div class="actions-bar">
      <div class="actions-bar-inner pkg actions">
              <button
                  type="submit"
                  class="action button primary primary-button mt-close-dialog"
                  title="Close"
                  >Close</button>
      </div>
  </div>  
 
</form>
 
<mt:include name="dialog/footer.tmpl">
 
 

結果

独自画面






最終更新:2012年03月11日 23:14