• 虹色ミツバチ
  • freoカスタマイズメモ、テンプレート・プラグイン配布/officeTIPS
検索プラグイン
虹色ミツバチ

> Entry >freo>freoTips>freo変数一覧> 新着エントリープラグインで新着エントリーの情報とオプションの内容を表示する方法

【freo】【freoTips】【freo変数一覧】新着エントリープラグインで新着エントリーの情報とオプションの内容を表示する方法

freoには、デフォルトで新着エントリー表示プラグインが実装されています。
デフォルト・エントリー・カテゴリー・個別エントリー表示(VIEW)画面で、管理画面で設定した件数分の新着エントリーを一覧表示できます。
上記画面で新着エントリーを一覧で表示する方法及び変数は以下のとおりです。

新着エントリーを一覧表示する

新着エントリーを一覧表示しているのは、[freo/templates/utility.html]の107~119行目

        <!--{if $plugin_entry_recentries|smarty:nodefaults}-->
        <div class="utility">
            <h3>新着エントリー</h3>
            <div class="content">
                <dl>
                    <!--{foreach from=$plugin_entry_recentries|smarty:nodefaults item='plugin_entry_recently'}-->
                    <dt><a href="{$freo.core.http_file}/view/{if $plugin_entry_recently.code}{$plugin_entry_recently.code}{else}{$plugin_entry_recently.id}{/if}">{$plugin_entry_recently.title}</a></dt>
                        <dd>{$plugin_entry_recently.datetime|date_format:'%Y/%m/%d %H:%M'}</dd>
                    <!--{/foreach}-->
                </dl>
            </div>
        </div>
        <!--{/if}-->

の部分です。

上記を解説すると

        <!--{もし新着エントリーがあったらここから}-->
        <div class="utility">
            <h3>新着エントリー</h3>
            <div class="content">
                <dl>
                    <!--{$plugin_entry_recentries配列を'plugin_entry_recently'として繰り返して表示するここから}-->
                    <dt><a href="{$freo設置URL}/view/{もし新着エントリーコードがあったらここから}{$新着エントリーコード}{そうじゃなければ}{$新着エントリーID}{もし新着エントリーコードがあったらここまで}">{$新着エントリータイトル}</a></dt>
                        <dd>{$新着エントリーの日付|日付を整形する'年/月/日 時:分'}</dd>
                    <!--{$plugin_entry_recentries配列を'plugin_entry_recently'として繰り返して表示するここまで}-->
                </dl>
            </div>
        </div>
        <!--{もし新着エントリーがあったらここまで}-->

以上のように、新着エントリー一覧としてエントリーのタイトル及び日付を一件ずつ繰り返して表示しています。

新着エントリーの情報を取得する方法

$plugin_entry_recentriesテーブルの情報をforeachする。

新着エントリーの情報は、「$plugin_entry_recentries」というテーブルに格納されています。
「$plugin_entry_recentries」テーブルの情報を表示したいときは、foreachしなければなりません。

とにかく、新着エントリーの情報を一覧表示したいなら、下記の通りにしなければならないってことです。

<!--{foreach from=$plugin_entry_recentries|smarty:nodefaults item='plugin_entry_recently'}-->

新着エントリーの情報を表示したい部分

<!--{/foreach}-->

上記のように、新着エントリーの情報の内一覧表示したい内容は、<!--{foreach from=$plugin_entry_recentries|smarty:nodefaults ~中略}-->と<!--{/foreach}-->で挟みます。
foreachの中に入れないで変数だけ書いても、新着エントリーの情報は表示されませんので注意して下さい。

エントリーの基本的な情報を表示するための変数
変数
{$plugin_entry_recently.id} 新着エントリーID
{$plugin_entry_recently.user_id} 新着エントリーの投稿者ユーザーID
{$plugin_entry_recently.created} 新着エントリーの投稿日時
{$plugin_entry_recently.modified} 新着エントリーの更新日時
{$plugin_entry_recently.approved} 新着エントリーの承認状況(yesまたはno)
{$plugin_entry_recently.restriction} 新着エントリーの閲覧制限(userまたはgroupまたはpasswordまたは無し)
{$plugin_entry_recently.password} 新着エントリーのパスワード
{$plugin_entry_recently.title} 新着エントリーのタイトル
{$plugin_entry_recently.status} 新着エントリーの状態(publishまたはprivateまたはfuture)
{$plugin_entry_recently.display} 新着エントリーの表示(pub;ishまたはprivate)
{$plugin_entry_recently.comment} 新着エントリーのコメントの受付(openまたはclosedまたはviewまたはuser)
{$plugin_entry_recently.trackback} 新着エントリーのトラックバックの受付(openまたはclosedまたはview)
{$plugin_entry_recently.title} 新着エントリーのタイトル
{$plugin_entry_recently.tag} 新着エントリーのタグ
{$plugin_entry_recently.datetime} 新着エントリーの日付
{$plugin_entry_recently.close} 新着エントリーの公開終了日時
{$plugin_entry_recently.file} 新着エントリーファイルのファイル名
{$plugin_entry_recently.image} 新着エントリーイメージのファイル名
{$plugin_entry_recently.memo} 新着エントリーファイルの説明
{$plugin_entry_recently.text} 新着エントリー本文
新着エントリーの添付ファイルの情報を表示する
新着エントリーファイルの情報を表示する

エントリーファイルの情報は$plugin_entry_recently_files[$plugin_entry_recently.id]配列に格納されています。

変数
{$plugin_entry_recently.file} 新着エントリーファイルのファイル名
{$plugin_entry_recently_files[$plugin_entry_recently.id].height} 新着エントリーファイルの高さ
{$plugin_entry_recently_files[$plugin_entry_recently.id].width} 新着エントリーファイルの横幅
{$plugin_entry_recently_files[$plugin_entry_recently.id].size} 新着エントリーファイルのサイズ
{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_files/{$plugin_entry_recently.id}/{$plugin_entry_recently.file} 新着エントリーファイルのURL
新着エントリーファイルのサムネイルの情報を表示する

エントリーファイルのサムネイルの情報は$plugin_entry_recently_thumbnails[$plugin_entry_recently.id]配列に格納されています。

変数
{$plugin_entry_recently.file} 新着エントリーファイルのサムネイルのファイル名
{$plugin_entry_recently_thumbnails[$plugin_entry_recently.id].height} 新着エントリーファイルの高さ
{$plugin_entry_recently_thumbnails[$plugin_entry_recently.id].width} 新着エントリーファイルの横幅
{$plugin_entry_recently_thumbnails[$plugin_entry_recently.id].size} 新着エントリーファイルのサイズ
{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_thumbnails/{$plugin_entry_recently.id}/{$plugin_entry_recently.file} 新着エントリーファイルのURL
新着エントリーイメージの情報を表示する

新着エントリーイメージの情報は$plugin_entry_recently_images[$plugin_entry_recently.id]配列に格納されています。

変数
{$plugin_entry_recently.image} 新着エントリーイメージのファイル名
{$plugin_entry_recently_images[$plugin_entry_recently.id].height} 新着エントリーイメージの高さ
{$plugin_entry_recently_images[$plugin_entry_recently.id].width} 新着エントリーイメージの横幅
{$plugin_entry_recently_images[$plugin_entry_recently.id].size} 新着エントリーイメージのサイズ
{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}entry_images/{$plugin_entry_recently.id}/{$plugin_entry_recently.image} 新着エントリーイメージのURL

斟酌エントリーのタグの情報を表示する

新着エントリーのタグは、「$plugin_entry_recently_tags[$plugin_entry_recently.id]」という配列に格納されています。
$plugin_entry_recently_tags[$plugin_entry_recently.id]に格納されているタグを表示するには、foreachしなければなりません。

<!--{foreach from=$plugin_entry_recently_tags[$plugin_entry_recently.id]|smarty:nodefaults item='plugin_entry_recently_tag' name='loop'}--><a href="{$freo.core.http_file}/entry?tag={$plugin_entry_recently_tag|smarty:nodefaults|escape:'url'}">{$plugin_entry_recently_tag}</a><!--{if !$smarty.foreach.loop.last}-->,&nbsp;<!--{/if}--><!--{/foreach}-->

新着エントリーのカテゴリーの情報を表示する

新着エントリーのカテゴリーについての情報は、$plugin_entry_recently_associates[$plugin_entry_recently.id].category」という配列に格納されています。
$plugin_entry_recently_associates[$plugin_entry_recently.id].categoryに格納されているカテゴリーを表示するには、foreachしなければなりません。

<!--{foreach from=$plugin_entry_recently_associates[$plugin_entry_recently.id].category|smarty:nodefaults key='plugin_entry_recently_category' item='plugin_entry_recently_category' name='loop'}--><a href="{$freo.core.http_file}/category/{$plugin_entry_recently_category}">{$freo.refer.categories[$plugin_entry_recently_category].name}</a><!--{if !$smarty.foreach.loop.last}-->,&nbsp;<!--{/if}--><!--{/foreach}-->

上記~

変数
{$plugin_entry_recently_category} 新着エントリーに紐付けられているカテゴリーID
{$freo.refer.categories[$plugin_entry_recently_category].name} 新着エントリーに紐付けられているカテゴリーIDのカテゴリー名

新着エントリーのオプションを表示する

オプションの表示方法には、二種類あります。
一括で表示するか、個別に表示するかです。

上記をふまえて、新着エントリーのオプションを取得するときに使用する変数は以下のとおりです。

変数
オプションを一括で表示する場合
{$plugin_entry_recently_associates[$plugin_entry_recently.id].option.[$option.id]} 新着エントリーのオプションIDが[$option.id]のオプションに登録されている内容
オプションを個別に表示する場合
{$plugin_entry_recently_associates[$plugin_entry_recently.id].option.取得したいオプションID}
※「取得したいオプションID」部分にはオプションIDを代入してください。
例)取得したいオプションIDが「test1」の場合は{$plugin_entry_recently_associates[$plugin_entry_recently.id].option.test1}
新着エントリーのオプションIDが「取得したいオプションID」のオプションに登録されている内容

説明すると、

{$plugin_entry_recently_associates[$plugin_entry_recently.id].option.[$option.id]}

こんな感じです。
つまり、

{$新着エントリーIDのエントリーのオプションのテーブルを指定して.オプションが.[$どのIDのオプションなのかを指定する]}

こういうことです。

オプションを個別に表示する場合は、[$option.id]部分に、[取得したいオプションID]を書き込みます

たとえば、オプションID「test1」のオプションを取得したいなら、

{$plugin_entry_recently_associates[$plugin_entry_recently.id].option.test1}

のようになります。

オプションを一括で表示する場合は、[$option.id]部分を取得するために、オプション格納テーブルの情報を取得する必要があります。

オプション格納テーブルには、そのfreoに登録されているオプションのID、名前などが格納されています。
詳細は、freo公式サイトの機能解説→本体のテーブル構成→オプション格納テーブルのページをご覧下さい。

オプション格納テーブルの情報を取得するには、foreachを使います。
つまり、

<!--{foreach from=$freo.refer.options|smarty:nodefaults item='option'}-->

オプションの情報を表示する部分

<!--{/foreach}-->

このようにします。

よって、ページのオプションを取得する場合は、

   <!--{foreach from=$freo.refer.options|smarty:nodefaults item='option'}-->

       {$plugin_entry_recently_associates[$plugin_entry_recently.id].option.[$option.id]}
<!--{/foreach}-->

 このようになります。

オプションを個別で表示するときのテンプレート編集例はfreo公式サイトの各機能の解説から「オプションを個別に表示する」を参考にしてください。

ページ移動

関連記事

ページ上部へ