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

> Entry >freo>freoTips>プラグイン系TIPS> サークル管理プラグインでサークルをカテゴリー別に一覧表示する方法

【freo】【freoTips】【プラグイン系TIPS】サークル管理プラグインでサークルをカテゴリー別に一覧表示する方法

freo公式サイトで配布されているサークル管理プラグインでは、登録されたサークルがサークル名順に一覧表示されるようになっています。
これを残したまま、サークルをカテゴリー別(同カテゴリー内ではサークル名順)に表示することができるようにしてみます。

サンプル

当サイトが利用しているfreoユーザーリンク集サークル管理プラグインを利用していますが、本リンク集でもこのTIPSを利用しています。
本リンク集にカテゴリー別表示メニューがありますので、そちらをご覧下さい。

サークルをカテゴリー別に一覧表示してみる。

本リンク集にあるカテゴリー順表示メニューでは、カテゴリー別に表示させた上で、カテゴリー名も表示させています。

  1. [freo/templates/plugins/circle/default.html]をコピーして同階層にペーストし、[freo/templates/plugins/circle/category.html]にリネームする。
  2. [freo/templates/plugins/circle/category.html]の11~44行目のサークル情報表示部分をまるっと変更してしまいます。
    <!--{foreach from=$plugin_circle_categories|smarty:nodefaults item='plugin_circle_category'}-->
        <h3><a href="{$freo.core.http_file}/circle?category={$plugin_circle_category.id}">{$plugin_circle_category.name}</a></h3>
        <table summary="サークル">
            <thead>
                <tr>
                    <th>サークル名</th>
                    <th>サークル代表者名</th>
                    <th>カテゴリー</th>
                    <th>タグ</th>
                    <th>登録日時</th>
                    <th>更新日時</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>サークル名</th>
                    <th>サークル代表者名</th>
                    <th>カテゴリー</th>
                    <th>タグ</th>
                    <th>登録日時</th>
                    <th>更新日時</th>
                </tr>
            </tfoot>
            <tbody>
                <!--{foreach from=$plugin_circles|smarty:nodefaults item='plugin_circle'}-->
                    <!--{if $plugin_circle_category.id == $plugin_circle.category_id}-->
                        <tr>
                            <td><a href="{$freo.core.http_file}/circle/view/{$plugin_circle.user_id}">{$plugin_circle.name}</a></td>
                            <td>{$plugin_circle.owner_name}</td>
                            <td><!--{if $plugin_circle.category_id}--><a href="{$freo.core.http_file}/circle?category={$plugin_circle.category_id}">{$plugin_circle_categories[$plugin_circle.category_id].name}</a><!--{/if}--></td>
                            <td><!--{foreach from=$plugin_circle_tags[$plugin_circle.user_id]|smarty:nodefaults item='plugin_circle_tag' name='loop'}--><a href="{$freo.core.http_file}/circle?tag={$plugin_circle_tag|smarty:nodefaults|escape:'url'}">{$plugin_circle_tag}</a><!--{if !$smarty.foreach.loop.last}-->,&nbsp;<!--{/if}--><!--{/foreach}--></td>
                            <td><!--{if $plugin_circle.created|date_format:'%Y%m%d' == $smarty.now|date_format:'%Y%m%d'}-->{$plugin_circle.created|date_format:'%H:%M:%S'}<!--{else}-->{$plugin_circle.created|date_format:'%Y/%m/%d'}<!--{/if}--></td>
                            <td><!--{if $plugin_circle.modified|date_format:'%Y%m%d' == $smarty.now|date_format:'%Y%m%d'}-->{$plugin_circle.modified|date_format:'%H:%M:%S'}<!--{else}-->{$plugin_circle.modified|date_format:'%Y/%m/%d'}<!--{/if}--></td>
                        </tr>
                    <!--{/if}-->
                <!--{/foreach}-->
            </tbody>
        </table>
    <!--{/foreach}-->
  3. [freo/templates/plugins/circle/category.html]をアップロードする。

解説するとこんな感じです

<!--{サークルのカテゴリーを繰り返して表示するここから}-->
    <h3><カテゴリー検索結果へのリンクここから>カテゴリー名</カテゴリー検索結果へのリンクここまで></h3>
    <table summary="サークル">
        <thead>
            <tr>
                サークル表示項目名(省略)
            </tr>
        </thead>
        <tfoot>
            <tr>
                サークル表示項目名(省略)
            </tr>
        </tfoot>
        <tbody>
            <!--{サークルの情報を繰り返して表示するここから}-->
                <!--{もし表示しているカテゴリーのIDがサークルのカテゴリーIDと同じだったらここから}-->
                    <tr>
                        サークルの情報(省略)
                    </tr>
                <!--{もし表示しているカテゴリーのIDがサークルのカテゴリーIDと同じだったらここまで}-->
            <!--{/サークルの情報を繰り返して表示するここまで}-->
        </tbody>
    </table>
<!--{サークルのカテゴリーを繰り返して表示するここまで}-->

ここまでで、[freo/index.php/circle/category]にアクセスすると、サークルがカテゴリー別(同カテゴリー内ではサークル名順)に表示されるはずです。

ページ移動

関連記事

ユーティリティ

Twitter

ページ上部へ