検索がヒットしなかった場合、検索結果には何も表示されません。
そこでヒット件数ゼロの場合に「該当するページが見つかりませんでした。」と表示するようにしました。
そこでヒット件数ゼロの場合に「該当するページが見つかりませんでした。」と表示するようにしました。
このカスタマイズはページ全体のHTML編集です。
マイブログメニューの[デザイン]⇒[HTML]から編集を行います。ソース下段あたりに次の記述があります。
マイブログメニューの[デザイン]⇒[HTML]から編集を行います。ソース下段あたりに次の記述があります。
<% if:page_name eq 'search' -%>
<% loop:list_article %>
<div class="blog">
<h2 class="date"><% article.createstamp | date_format("%Y年%m月%d日") %></h2>
<div class="blogbody">
<h3 class="title"><a href="<% article.page_url %>" class="title"><% article.subject %></a></h3>
<div class="text"><% article.entire_body | text_summary(240) %></div>
<div class="posted">posted by <% article.nickname %> at <% article.createstamp | date_format("%H:%M") -%></div>
</div>
</div>
<% /loop %>
<% /if -%>
<% loop:list_article %>
<div class="blog">
<h2 class="date"><% article.createstamp | date_format("%Y年%m月%d日") %></h2>
<div class="blogbody">
<h3 class="title"><a href="<% article.page_url %>" class="title"><% article.subject %></a></h3>
<div class="text"><% article.entire_body | text_summary(240) %></div>
<div class="posted">posted by <% article.nickname %> at <% article.createstamp | date_format("%H:%M") -%></div>
</div>
</div>
<% /loop %>
<% /if -%>
※各カスタマイズの紹介を独立させるために、初期状態のソースで説明します。
<% if:page_name eq 'search' -%>〜<% /if -%>が検索結果ページに関する記述です。
次の赤字の1行を追加しました。
次の赤字の1行を追加しました。
<% if:page_name eq 'search' -%>
<% loop:list_article %>
<div class="blog">
<h2 class="date"><% article.createstamp | date_format("%Y年%m月%d日") %></h2>
<div class="blogbody">
<h3 class="title"><a href="<% article.page_url %>" class="title"><% article.subject %></a></h3>
<div class="text"><% article.entire_body | text_summary(240) %></div>
<div class="posted">posted by <% article.nickname %> at <% article.createstamp | date_format("%H:%M") -%></div>
</div>
</div>
<% /loop %>
<% unless:list_article %>該当するページが見つかりませんでした。<% /unless %>
<% /if -%>
<% loop:list_article %>
<div class="blog">
<h2 class="date"><% article.createstamp | date_format("%Y年%m月%d日") %></h2>
<div class="blogbody">
<h3 class="title"><a href="<% article.page_url %>" class="title"><% article.subject %></a></h3>
<div class="text"><% article.entire_body | text_summary(240) %></div>
<div class="posted">posted by <% article.nickname %> at <% article.createstamp | date_format("%H:%M") -%></div>
</div>
</div>
<% /loop %>
<% unless:list_article %>該当するページが見つかりませんでした。<% /unless %>
<% /if -%>
以上で作業は完了です。変更後は次のように表示されます。
