Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save webbingstudio/bc9890cc68aeaf54d270d985c5ceb5c2 to your computer and use it in GitHub Desktop.
Save webbingstudio/bc9890cc68aeaf54d270d985c5ceb5c2 to your computer and use it in GitHub Desktop.
a-blog cmsのカスタムユニット:ファイル
<style>
.acms-admin-ex-notice {
margin: 5px 0;
padding: 5px;
background-color: #F9F9F9;
color: #339900;
font-size: .75rem;
line-height: 1.25;
}
</style>
<!-- BEGIN custom_hoge -->
<table class="entryFormColumnSettingTable entryFormColumnTable">
<tr>
<td class="entryFormFileControl">
<table class="entryFormColumnSettingTable">
<!-- ユニットの入力項目:ファイルの場合 -->
<tr>
<th style="white-space: nowrap;">ファイル</th>
<td>
<!-- BEGIN_IF [{hoge_file@path}/nem] -->
<input type="hidden" name="hoge_file{id}@old" value="{hoge_file@path}" />
<input type="hidden" name="hoge_file{id}@secret" value="{hoge_file@secret}" />
<input type="hidden" name="hoge_file{id}@fileSize" value="{hoge_file@fileSize}" />
<label for="input-checkbox-hoge_file@edit" class="acms-admin-form-checkbox">
<input type="checkbox" name="hoge_file{id}@edit" value="delete" id="input-checkbox-hoge_file@edit" />
<i class="acms-admin-ico-checkbox"></i> 削除
</label>
<a href="%{ARCHIVES_DIR}{hoge_file@path}"><img src="/images/fileicon/pdf.gif" width="64" height="64" alt="pdf" /></a>
{hoge_file@baseName}<br />
<!-- END_IF -->
<input type="file" name="hoge_file{id}" size="20" />
<input type="hidden" name="unit{id}[]" value="hoge_file{id}" />
<input type="hidden" name="hoge_file{id}@baseName" value="{hoge_file@baseName}" />
<input type="hidden" name="hoge_file{id}:extension" value="file" />
<input type="hidden" name="hoge_file{id}@extension" value="pdf" />
<input type="hidden" name="hoge_file{id}@filename" value="pdf/entry-%{EID}-{id}.pdf" />
<p class="acms-admin-ex-notice">入力項目の説明文です入力項目の説明文です入力項目の説明文です入力項目の説明文です入力項目の説明文です入力項目の説明文です</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END custom_hoge -->
<!-- BEGIN unit#custom_hoge -->
<table class="acms-table acms-table-borderd">
<!-- ユニットの表示:ファイルの場合 -->
<tr>
<th>ファイル</th>
<td>
<!-- BEGIN_IF [{hoge_file@path}/nem] -->
<a href="%{ARCHIVES_DIR}{hoge_file@path}" target="_blank"><img src="/images/fileicon/pdf.gif" width="64" height="64" alt="pdf" /></a>
<!-- END_IF -->
</td>
</tr>
</table>
<!-- END unit#custom_hoge -->
@webbingstudio
Copy link
Author

webbingstudio commented May 9, 2016

ファイルユニットに使用されているtd.entryFormFileControlを改変。モバイルに対応する。
td.entryFormFileControlは、th要素の幅が8emと狭いので、th要素にnowrapを明示している。
p.acms-admin-ex-notice は注釈を表示するための追加クラス。2.6の時点ではacms.cssにちょうど良いコンポーネントがないので…

a-blog cms本来のファイルユニットとは異なり、ファイルパスを指定することができるので、後々再利用する可能性があるファイルの管理に適している。
この例では以下の場所にアップロードされる。

/archives/pdf/entry-(エントリーID)-(ユニットID).pdf

ただし、拡張子を明示する必要があるため、PDFとスプレッドシートを混在させるといったことはできない。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment