【freo】【freoTips】【プラグイン系TIPS】エントリーギャラリー表示プラグインで画像以外のファイルを表示させない方法
- 2014/02/25 03:38
- エントリーギャラリー表示プラグイン
- エントリー
- 画像
- イメージ
- ファイル
- 56
エントリーギャラリー表示プラグインはfreoにデフォルトで搭載されているプラグインです。
エントリーに登録されている画像を一覧表示します。
デフォルトではデフォルト画面・エントリー画面・カテゴリー画面・日記記事表示(VIEW)画面などのサイドバーに「新着画像」として利用されています。
エントリーにイメージが登録されていた場合はイメージを
エントリーにサムネイルが登録されていた場合はサムネイルを
エントリーにファイルが登録されていた場合はファイルを
エントリーの本文に画像が貼られていた場合は画像を
1件のみ表示しています。
エントリーに登録されているファイルが画像でない場合(例えば、ZIP・TXT・PDFなど)でも新着画像として表示されてしまいますが、画像が登録されていた場合のみ表示するためには、テンプレートの書き換えが必要です。
[freo/templates/utility.html]の106~117行目
<!--{if $plugin_entry_galleries|smarty:nodefaults}--> <div class="utility"> <h3>新着画像</h3> <div class="content"> <ul class="gallery"> <!--{foreach from=$plugin_entry_galleries|smarty:nodefaults item='plugin_entry_gallery'}--> <li><a href="{$freo.core.http_file}/view/{if $plugin_entry_gallery.code}{$plugin_entry_gallery.code}{else}{$plugin_entry_gallery.id}{/if}"><!--{if $plugin_entry_gallery.image}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_images/{$plugin_entry_gallery.id}/{$plugin_entry_gallery.image}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{elseif $plugin_entry_gallery_thumbnails[$plugin_entry_gallery.id]}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_thumbnails/{$plugin_entry_gallery.id}/{$plugin_entry_gallery.file}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{elseif $plugin_entry_gallery.file}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_files/{$plugin_entry_gallery.id}/{$plugin_entry_gallery.file}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{elseif $plugin_entry_gallery_medias[$plugin_entry_gallery.id].file}--><img src="{$plugin_entry_gallery_medias[$plugin_entry_gallery.id].file}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{else}-->{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}<!--{/if}--></a></li> <!--{/foreach}--> </ul> </div> </div> <!--{/if}-->
を、以下のように変更します。
<!--{if $plugin_entry_galleries|smarty:nodefaults}--> <div class="utility"> <h3>新着画像</h3> <div class="content"> <ul class="gallery"> <!--{foreach from=$plugin_entry_galleries|smarty:nodefaults item='plugin_entry_gallery'}--> <li><a href="{$freo.core.http_file}/view/{if $plugin_entry_gallery.code}{$plugin_entry_gallery.code}{else}{$plugin_entry_gallery.id}{/if}"><!--{if $plugin_entry_gallery.image}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_images/{$plugin_entry_gallery.id}/{$plugin_entry_gallery.image}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{elseif $plugin_entry_gallery_thumbnails[$plugin_entry_gallery.id]}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_thumbnails/{$plugin_entry_gallery.id}/{$plugin_entry_gallery.file}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{elseif $plugin_entry_gallery.file and $plugin_entry_gallery_files[$plugin_entry_gallery.id].width and $plugin_entry_gallery_files[$plugin_entry_gallery.id].height}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_files/{$plugin_entry_gallery.id}/{$plugin_entry_gallery.file}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{elseif $plugin_entry_gallery_medias[$plugin_entry_gallery.id].file}--><img src="{$plugin_entry_gallery_medias[$plugin_entry_gallery.id].file}" alt="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" title="{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}" /><!--{else}-->{$plugin_entry_gallery.memo|default:$plugin_entry_gallery.title}<!--{/if}--></a></li> <!--{/foreach}--> </ul> </div> </div> <!--{/if}-->
つまりこういうことです↓
<!--{もし新着画像のあるエントリーがあったらここから}--> <div class="utility"> <h3>新着画像</h3> <div class="content"> <ul class="gallery"> <!--{新着画像のあるエントリーを'plugin_entry_gallery'として繰り返すここから}--> <li><a href="{$freo.core.http_file}/view/{if $plugin_entry_gallery.code}{$plugin_entry_gallery.code}{else}{$plugin_entry_gallery.id}{/if}"><!--{もし新着画像のあるエントリーにイメージがあったらここから}--><img src="新着画像のあるエントリーイメージのURL" alt="新着画像のあるエントリーファイルの説明|ファイルの説明が登録されてなければ新着画像のある記事のタイトル" title="新着画像のあるエントリーファイルの説明|ファイルの説明が登録されてなければ新着画像のある記事のタイトル" /><!--{またはもし新着画像のあるエントリーにサムネイルがあれば}--><img src="新着画像のあるエントリーのサムネイルのURL" alt="新着画像のあるエントリーファイルの説明|ファイルの説明が登録されてなければ新着画像のあるエントリー記事のタイトル" title="新着画像のあるエントリーファイルの説明|ファイルの説明が登録されてなければ新着画像のあるエントリー記事のタイトル" /><!--{またはもし新着画像のあるエントリーファイルがあってファイルに横幅があってファイルに縦幅があれば}--><img src="新着画像のあるエントリーファイルのURL" alt="新着画像のあるエントリーファイルの説明|ファイルの説明が登録されてなければ新着画像のあるエントリー記事のタイトル" title="新着画像のあるエントリーファイルの説明|ファイルの説明が登録されてなければ新着画像のあるエントリー記事のタイトル" /><!--{またはもし新着画像のあるエントリー本文に画像が添付されてれば}--><img src="新着画像のあるエントリー本文に添付されている画像のURL" alt="新着画像のあるエントリー本文に添付されている画像の説明|画像の説明が登録されてなければ新着画像のあるエントリー記事のタイトル" title="画像の説明が登録されてなければ新着画像のあるエントリー記事のタイトル" /><!--{そうじゃなければ}-->新着画像のあるエントリーのファイルの説明|ファイルの説明が登録されてなければエントリータイトル<!--{もし新着画像イメージがあったらここまで}--></a></li> <!--{新着画像を'plugin_entry_gallery'として繰り返すここまで}--> </ul> </div> </div> <!--{もし新着画像があったらここまで}-->