<?php
$template = <<<END
<!-- shop11_grid: グリッド1 -->
<section class="shop11_grid">
<!--{def item/title}-->
<h2>{val item/title}</h2>
<!--{/def}-->

<!--{def item/grid_type}-->
<div class="list-grid2">
<!--{/def}-->
<!--{ndef item/grid_type}-->
<div class="list-grid1">
<!--{/ndef}-->
<!--{each item/list}-->
<!--{def item/list/name}-->
<div class="list">
<!--{def item/list/image}-->
<figure><img src="user_data/{val item/list/image}" alt=""></figure>
<!--{/def}-->
<div class="text">
<h4>{val item/list/name}</h4>
<p class="markdown-body">{rval item/list/text}</p>
<!--{def item/grid_type}-->
<!--{def item/list/link}-->
<p class="btn1-maru"><a href="{val item/list/link}">詳しくみる</a></p>
<!--{/def}-->
<!--{/def}-->
</div>
<!--{ndef item/grid_type}-->
<!--{def item/list/link}-->
<p class="btn1-maru"><a href="{val item/list/link}">詳しくみる</a></p>
<!--{/def}-->
<!--{/ndef}-->
<!--{def item/list/badge}-->
<span class="{val item/list/badge_icon}">{val item/list/badge}</span>
<!--{/def}-->
</div>
<!--{/def}-->
<!--{/each}-->
</div>
</section>
END;

$shop11_grid = array(
		"title" => "shop11 グリッド",
		"name" => "shop11_grid",			// 名称、重複すると正しく動作しません
		"template" => $template,		// ブロックのテンプレート
		"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=shop11_grid",
			"class" => "notice",
		),
			"title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"grid_type" => array(
				"title" => "表示タイプ",
				"type" => "select",
				"list" => array(
					"" => "縦",
					"list-grid2" => "横",
				),
			),
			"dummy1" => array(
				"title" => " ",
				"type" => "comment",
			),
			"name1" => array(
				"title" => "名称1",
				"type" => "text",
			),
			"text1" => array(
				"title" => "説明1",
				"type" => "textarea",
			),
			"image1" => array(
				"title" => "画像1",
				"type" => "image",
			),
			"link1" => array(
				"title" => "リンク1",
				"type" => "text",
			),
			"badge1" => array(
				"title" => "バッジ1",
				"type" => "text",
			),
			"badge_icon1" => array(
				"title" => "バッジアイコン1",
				"type" => "select",
				"list" => array(
					"" => "なし",
					"newicon" => "あり",
				),
			),
			"dummy2" => array(
				"title" => " ",
				"type" => "comment",
			),
			"name2" => array(
				"title" => "名称2",
				"type" => "text",
			),
			"text2" => array(
				"title" => "説明2",
				"type" => "textarea",
			),
			"image2" => array(
				"title" => "画像2",
				"type" => "image",
			),
			"link2" => array(
				"title" => "リンク2",
				"type" => "text",
			),
			"badge2" => array(
				"title" => "バッジ2",
				"type" => "text",
			),
			"badge_icon2" => array(
				"title" => "バッジアイコン2",
				"type" => "select",
				"list" => array(
					"" => "なし",
					"newicon" => "あり",
				),
			),
			"dummy3" => array(
				"title" => " ",
				"type" => "comment",
			),
			"name3" => array(
				"title" => "名称3",
				"type" => "text",
			),
			"text3" => array(
				"title" => "説明3",
				"type" => "textarea",
			),
			"image3" => array(
				"title" => "画像3",
				"type" => "image",
			),
			"link3" => array(
				"title" => "リンク3",
				"type" => "text",
			),
			"badge3" => array(
				"title" => "バッジ3",
				"type" => "text",
			),
			"badge_icon3" => array(
				"title" => "バッジアイコン3",
				"type" => "select",
				"list" => array(
					"" => "なし",
					"newicon" => "あり",
				),
			),
			"dummy4" => array(
				"title" => " ",
				"type" => "comment",
			),
			"name4" => array(
				"title" => "名称4",
				"type" => "text",
			),
			"text4" => array(
				"title" => "説明4",
				"type" => "textarea",
			),
			"image4" => array(
				"title" => "画像4",
				"type" => "image",
			),
			"link4" => array(
				"title" => "リンク4",
				"type" => "text",
			),
			"badge4" => array(
				"title" => "バッジ4",
				"type" => "text",
			),
			"badge_icon4" => array(
				"title" => "バッジアイコン4",
				"type" => "select",
				"list" => array(
					"" => "なし",
					"newicon" => "あり",
				),
			),
			"dummy5" => array(
				"title" => " ",
				"type" => "comment",
			),
			"name5" => array(
				"title" => "名称5",
				"type" => "text",
			),
			"text5" => array(
				"title" => "説明5",
				"type" => "textarea",
			),
			"image5" => array(
				"title" => "画像5",
				"type" => "image",
			),
			"link5" => array(
				"title" => "リンク5",
				"type" => "text",
			),
			"badge5" => array(
				"title" => "バッジ5",
				"type" => "text",
			),
			"badge_icon5" => array(
				"title" => "バッジアイコン5",
				"type" => "select",
				"list" => array(
					"" => "なし",
					"newicon" => "あり",
				),
			),
			"dummy6" => array(
				"title" => " ",
				"type" => "comment",
			),
			"name6" => array(
				"title" => "名称6",
				"type" => "text",
			),
			"text6" => array(
				"title" => "説明6",
				"type" => "textarea",
			),
			"image6" => array(
				"title" => "画像6",
				"type" => "image",
			),
			"link6" => array(
				"title" => "リンク6",
				"type" => "text",
			),
			"badge6" => array(
				"title" => "バッジ6",
				"type" => "text",
			),
			"badge_icon6" => array(
				"title" => "バッジアイコン6",
				"type" => "select",
				"list" => array(
					"" => "なし",
					"newicon" => "あり",
				),
			),
		),
		"func" => "func_shop11_grid",		// 処理プログラム（指定がない物は標準処理）
	);

block_add($shop11_grid);

function func_shop11_grid($def, $info)
{
	$list = array();
	for ($i = 1; $i <= 10; $i++) {
		unset($item);
		if ($info["name" . $i]) {
			$item["name"] = $info["name" . $i];
			$item["text"] = $info["text" . $i];
			$item["link"] = $info["link" . $i];
			$item["badge"] = $info["badge" . $i];
			$item["badge_icon"] = $info["badge_icon" . $i];
			if ($info["image" . $i]) {
				$item["image"] = $info["image" . $i . "_file"];
			}
		}
		$list[] = $item;
	}
	$info["list"] = $list;
	return $info;
}
