【freo】【freoTips】【オプション系TIPS】freoプラグインで利用すると便利なオプション登録例
- 2014/03/07 20:00
- オプション登録例
- プラグインオプション
- バナー付きリンクプラグイン
- スケジュールプラグイン
- 55
freoの一部のプラグインには、「オプション」を登録することができます。たとえば、freo公式で配布されている「ショッピングカートプラグイン」、「プロフィール拡張プラグイン」や、
当サイトで配布している「ニュースプラグイン」「バナー付きリンクプラグイン」「スケジュールプラグイン」などです。
この記事では、プラグインのオプションに登録すると便利なオプションを紹介します。
バナー付きリンクプラグインで利用すると便利なオプション
管理者名
サイトの管理者名を登録するためのオプションです。
オプションID | option + 各オプションの番号が自動で割り振られています。 変更はできません。 (例:option01) |
---|---|
オプション名 | 管理者名 |
種類 | 一行テキストボックス |
初期値 | (空欄) |
テンプレート記述例
リンク一覧ページにサイト名などの他に管理者も同時に表示します。
[freo/templates/plugins/link/default.html]の29~78行目を
<table id="link"> <tbody> <!--{foreach from=$plugin_links|smarty:nodefaults item='plugin_link'}--> <tr> <td> <a href="{$freo.core.http_file}/link/view/{$plugin_link.id}"><!--{if $plugin_link_files[$plugin_link.id].file}-->{$plugin_link.title}<br /><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}plugins/link_files/{$plugin_link.id}/{$plugin_link_files[$plugin_link.id].file}" alt="{$plugin_link.title}" /><!--{elseif $plugin_link.imageurl}-->{$plugin_link.title}<br /><img src="{$plugin_link.imageurl}" alt="{$plugin_link.title}" /><!--{else}-->{$plugin_link.title}<!--{/if}--></a> </td> <td> <!--{if $plugin_link.option01}-->管理者:{$plugin_link.option01}様<br /><!--{/if}--> <!--{if $plugin_link.category_id}-->カテゴリー:<a href="{$freo.core.http_file}/link?category_id={$plugin_link.category_id}">{$plugin_link_categories[$plugin_link.category_id].name}</a><br /><!--{/if}--> <!--{if $plugin_link_tags[$plugin_link.id]}-->タグ:<!--{foreach from=$plugin_link_tags[$plugin_link.id]|smarty:nodefaults item='plugin_link_tag' name='loop'}--><a href="{$freo.core.http_file}/link?tag={$plugin_link_tag|smarty:nodefaults|escape:'url'}">{$plugin_link_tag}</a><!--{if !$smarty.foreach.loop.last}-->, <!--{/if}--><!--{/foreach}--><br /><!--{/if}--> <!--{if $plugin_link.text}-->{$plugin_link.text|nl2br}<!--{/if}--> </td> </tr> <!--{/foreach}--> </tbody> </table>
上記のように編集すると、管理者名も含めたリンク情報を表示できます。
スケジュールプラグインで利用すると便利なオプション
公開範囲
スケジュールをログインしていないユーザーに閲覧させるかどうかを選択できます。
オプションID | option + 各オプションの番号が自動で割り振られています。 変更はできません。 (例:option01) |
---|---|
オプション名 | 公開範囲 |
種類 | セレクトボックス |
初期値 | 公開,ユーザーのみに公開,非公開 (※ここでは分かりやすくするため項目を『,』で区切っていますが、実際のオプション登録画面では、項目と項目は『,』ではなく改行で区切ってください) |
テンプレート記述例
スケジュール一覧画面(freo/index.php/schedule)やスケジュール記事画面(freo/index.php/schedule/view/スケジュールID)で公開範囲を「公開」に設定したスケジュールをユーザーにのみ表示したり非公開にしたりする方法は以下のとおりです。
[freo/templates/plugins/schedule/default.html]の23~64行目を
<!--{foreach from=$plugin_schedules|smarty:nodefaults item='plugin_schedule'}--> <!--{if $plugin_schedule.option01 == 'ユーザーのみに公開' and ($freo.user.authority == 'root' or $freo.user.authority == 'author')}--> <h3><!--{if $plugin_schedule.url}--><a href="{if $plugin_schedule.url|regex_match:'/^https?\:\/\//'}{$plugin_schedule.url}{else}{$freo.core.http_file}/{$plugin_schedule.url}{/if}" target="_blank">{$plugin_schedule.title}</a><!--{else}-->{$plugin_schedule.title}<!--{/if}--><!--{if $freo.user.authority == 'root' or $freo.user.authority == 'author'}--><a href="{$freo.core.http_file}/schedule/admin_form?id={$plugin_schedule.id}"><img src="{$freo.core.http_url}images/icons/edit.png" alt="編集" title="編集" width="16" height="16" /></a><!--{/if}--></h3> <dl class="schedule"> <dt>日時</dt> <dd><a href="{$freo.core.http_file}/schedule/view/{$plugin_schedule.id}">{$plugin_schedule.datetime|date_format:'%Y/%m/%d %H:%M:%S'}~{$plugin_schedule.enddatetime|date_format:'%Y/%m/%d %H:%M:%S'}</a></dd> <dt>場所</dt> <dd>{$plugin_schedule.place}</dd> <dt>コメント</dt> <dd>{$plugin_schedule.text|mb_truncate:50:'...'}</dd> <dt>カテゴリー</dt> <dd><a href="{$freo.core.http_file}/schedule?category_id={$plugin_schedule.category_id}">{$plugin_schedule_categories[$plugin_schedule.category_id].name}</a></dd> <dt>イメージ</dt> <dd><!--{if $plugin_schedule_files[$plugin_schedule.id].file}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}plugins/schedule_files/{$plugin_schedule.id}/{$plugin_schedule_files[$plugin_schedule.id].file}" alt="{$plugin_schedule.title}" /><!--{/if}--></dd> <dt>タグ</dt> <dd><!--{foreach from=$plugin_schedule_tags[$plugin_schedule.id]|smarty:nodefaults item='plugin_schedule_tag' name='loop'}--><a href="{$freo.core.http_file}/schedule?tag={$plugin_schedule_tag|smarty:nodefaults|escape:'url'}">{$plugin_schedule_tag}</a><!--{if !$smarty.foreach.loop.last}-->, <!--{/if}--><!--{/foreach}--></dd> </dl> <!--{elseif $plugin_schedule.option01 == '非公開'}--> <!--{elseif $plugin_schedule.option01 == '公開'}--> <h3><!--{if $plugin_schedule.url}--><a href="{if $plugin_schedule.url|regex_match:'/^https?\:\/\//'}{$plugin_schedule.url}{else}{$freo.core.http_file}/{$plugin_schedule.url}{/if}" target="_blank">{$plugin_schedule.title}</a><!--{else}-->{$plugin_schedule.title}<!--{/if}--><!--{if $freo.user.authority == 'root' or $freo.user.authority == 'author'}--><a href="{$freo.core.http_file}/schedule/admin_form?id={$plugin_schedule.id}"><img src="{$freo.core.http_url}images/icons/edit.png" alt="編集" title="編集" width="16" height="16" /></a><!--{/if}--></h3> <dl class="schedule"> <dt>日時</dt> <dd><a href="{$freo.core.http_file}/schedule/view/{$plugin_schedule.id}">{$plugin_schedule.datetime|date_format:'%Y/%m/%d %H:%M:%S'}~{$plugin_schedule.enddatetime|date_format:'%Y/%m/%d %H:%M:%S'}</a></dd> <dt>場所</dt> <dd>{$plugin_schedule.place}</dd> <dt>コメント</dt> <dd>{$plugin_schedule.text|mb_truncate:50:'...'}</dd> <dt>カテゴリー</dt> <dd><a href="{$freo.core.http_file}/schedule?category_id={$plugin_schedule.category_id}">{$plugin_schedule_categories[$plugin_schedule.category_id].name}</a></dd> <dt>イメージ</dt> <dd><!--{if $plugin_schedule_files[$plugin_schedule.id].file}--><img src="{$freo.core.http_url}{$smarty.const.FREO_FILE_DIR}plugins/schedule_files/{$plugin_schedule.id}/{$plugin_schedule_files[$plugin_schedule.id].file}" alt="{$plugin_schedule.title}" /><!--{/if}--></dd> <dt>タグ</dt> <dd><!--{foreach from=$plugin_schedule_tags[$plugin_schedule.id]|smarty:nodefaults item='plugin_schedule_tag' name='loop'}--><a href="{$freo.core.http_file}/schedule?tag={$plugin_schedule_tag|smarty:nodefaults|escape:'url'}">{$plugin_schedule_tag}</a><!--{if !$smarty.foreach.loop.last}-->, <!--{/if}--><!--{/foreach}--></dd> </dl> <!--{/if}--> <!--{/foreach}-->
上記のように編集すると、管理者名も含めたリンク情報を表示できます。
解説:
<!--{スケジュール配列の繰り返しここから}--><!--{もしオプション01の内容が'ユーザーのみに公開'である かつ ユーザーが管理者または投稿者だったらここから}-->
~スケジュール表示(省略)~
<!--{またはもしオプション01の内容が非公開だったら}-->
<!--{またはもしオプション01の内容が公開だったら}-->
~スケジュール表示(省略)~
<!--{もしオプション01の内容が'ユーザーのみに公開'である かつ ユーザーが管理者または投稿者だったらここまで}-->
<!--{スケジュール配列の繰り返しここまで}-->