「テンプレート:飲食店ジャンルページ」の版間の差分
提供: 川西図鑑
その他の操作
ページの作成:「<noinclude> {{#template_params:}} </noinclude><includeonly> {{#template_display:_format=table}}</includeonly>」 |
編集の要約なし |
||
| (同じ利用者による、間の25版が非表示) | |||
| 1行目: | 1行目: | ||
< | <templatestyles src="検索結果カード/styles.css" /> | ||
{{# | <templatestyles src="飲食店一覧ページ/styles.css" /> | ||
</ | {{パンくずリスト|1=飲食店検索|2={{{genre}}}}} | ||
{{# | <div class="search-intro"> | ||
<p> | |||
川西市で人気の<strong>{{{genre}}}</strong>のお店を一覧でご紹介しています。 | |||
</p> | |||
<p> | |||
下の検索フォームを使えば、さらに条件を絞り込んで探すこともできます。 | |||
</p> | |||
</div> | |||
== 検索条件 == | |||
<!-- 検索ボックス --> | |||
{{検索UI/飲食店|action=/wiki/飲食店検索}} | |||
<html> | |||
<script> | |||
document.getElementById('searchForm').addEventListener('submit', function (e) { | |||
const searchText = document.getElementById('searchText'); | |||
const genre = document.getElementById('genre'); | |||
const station = document.getElementById('station'); | |||
const budget_min = document.getElementById('budget_min'); | |||
const budget_max = document.getElementById('budget_max'); | |||
if (searchText.value === '') { | |||
searchText.removeAttribute('name'); // 空のとき name属性を削除 | |||
} | |||
if (genre.value === '') { | |||
genre.removeAttribute('name'); // 空のとき name属性を削除 | |||
} | |||
if (station.value === '') { | |||
station.removeAttribute('name'); // 空のとき name属性を削除 | |||
} | |||
if (budget_min.value === '') { | |||
budget_min.removeAttribute('name'); // 空のとき name属性を削除 | |||
} | |||
if (budget_max.value === '') { | |||
budget_max.removeAttribute('name'); // 空のとき name属性を削除 | |||
} | |||
}); | |||
document.addEventListener('DOMContentLoaded', function () { | |||
const clearBtn = document.querySelector('.clear-btn'); | |||
const form = document.getElementById('searchForm'); | |||
clearBtn.addEventListener('click', function () { | |||
form.reset(); | |||
}); | |||
form.action = '/wiki/飲食店検索'; | |||
const titleEl = document.querySelector('.mw-page-title-main'); | |||
const genre = titleEl ? titleEl.textContent.trim() : 'グルメ'; | |||
// タイトル生成 | |||
let title = `川西市でおすすめのおいしい${genre}をご紹介! | 川西図鑑`; | |||
// タイトル更新 | |||
document.title = title; | |||
// セレクトボックス制御 | |||
const el = document.querySelector(`[name="genre"]`); | |||
if (el) el.value = genre;; | |||
var count = document.getElementById("count"); | |||
count = count.dataset.total.toString(); | |||
if (count) { | |||
count = count + "件"; | |||
} else { | |||
count = ""; | |||
} | |||
// description生成 | |||
let desc = `「川西図鑑」では、兵庫県川西市で人気の${genre}のお店を ${count}掲載中。営業時間、アクセス、写真、地図などの詳細情報をまとめています。ランチやディナー、テイクアウトなど条件で絞り込みができ、地元でおすすめのお店が見つかります。`; | |||
let meta = document.querySelector("meta[name='description']"); | |||
if (!meta) { | |||
meta = document.createElement("meta"); | |||
meta.name = "description"; | |||
document.head.appendChild(meta); | |||
} | |||
meta.content = desc; | |||
});//# sourceURL=foobar.js | |||
</script> | |||
</html> | |||
{{#vardefine:hitCount | | |||
{{#cargo_query: | |||
tables=図鑑情報 | |||
|fields=COUNT(*) | |||
|where=( | |||
図鑑情報.カテゴリ='飲食店' AND | |||
図鑑情報.ジャンル LIKE CONCAT('%{{{genre}}}%') | |||
) | |||
}} | |||
}} | |||
{{#vardefine:page|{{#urlget:page|1}}}} | |||
{{#vardefine:limit|30}} | |||
{{#vardefine:offset| | |||
{{#expr: ({{#var:page}} - 1) * {{#var:limit}} }} | |||
}} | |||
{{#vardefine:from| | |||
{{#expr: | |||
({{#var:page}} - 1) * {{#var:limit}} + 1 | |||
}} | |||
}} | |||
<h1 style="font-size: 1.2em;"> | |||
<strong>{{#if: {{#urlget:station}} | {{#urlget:station}} |川西市}}</strong>の<strong>{{{genre}}}</strong></h1><strong style="float: right;" id="count" data-total="{{#var:hitCount}}" data-limit="{{#var:limit}}">{{#var:hitCount}} 件の結果があります({{#var:from}} 件目~) | |||
</strong> | |||
== 検索結果 == | |||
<!-- 検索実行 --> | |||
{{#cargo_query: | |||
tables=図鑑情報 | |||
|fields=図鑑情報._pageName,図鑑情報.店名,図鑑情報.画像,図鑑情報.ジャンル,図鑑情報.郵便番号,図鑑情報.住所,図鑑情報.最寄り,図鑑情報.営業時間月,図鑑情報.定休日,図鑑情報.電話番号,図鑑情報.予算昼下限,図鑑情報.予算昼上限,図鑑情報.予算夜下限,図鑑情報.予算夜上限,図鑑情報.ストリートビューURL,図鑑情報.座標 | |||
|where=( | |||
図鑑情報.カテゴリ='飲食店' AND | |||
図鑑情報.ジャンル LIKE CONCAT('%{{{genre}}}%') | |||
) | |||
|format=template | |||
|template=検索結果カード | |||
|named args=yes | |||
|default=該当する店舗はありません。 | |||
|limit={{#var:limit}} | |||
|offset={{#var:offset}} | |||
|order by=score DESC | |||
|more results text= | |||
}} | |||
{{ページネーション}} | |||
__目次非表示__ | |||