5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

concrete5.7 テーマ(最少)を作ってみる。

Last updated at Posted at 2016-02-04

はじめに

concrete5 のテーマが動く、最少のファイルを作ってみます。

更新履歴

2016.02.05-1
$a->display();$a->display($c); に変更しました。$c は、表示するページのオブジェクトです。
Loader::element('footer_required'); が、</body> 直前になってなかった。

2016.02.05-2
$a->display($c);$a->display(); に戻しました。5.7 からは省略可能になったようです。

テーマファイルの置き場所

/application/themes/

themes (シームスと読むそうです)フォルダ以下に、作りたいテーマの名前フォルダを作ります。

/application/themes/tm1

これで「tm1」という名前のテーマが存在していると認識されます。管理画面のテーマを選択すると、中身が何もないのに、「tm1」をインストールするか聞いてきます。

01.jpg

中身がないので、サムネイルも名前も説明も何もなしです。

default.php を作る

最低限、default.php があるとテーマが使えるようになるようなので、default.php を作ってみました。UTF-8 で保存しましょう。

application/themes/tm1/default.php
<?php
	// おまじない
	defined('C5_EXECUTE') or die("Access Denied.");
?>
<html>
<head>
<?php
	// concrete5 の動作に必要な、<head> タグ内コードを出力
	Loader::element('header_required');
?>
</head>
<body>
<!-- 編集時 concrete5 の上部メニューの表示で、コンテンツが隠れてしまうのを予防します -->
<div class="<?php echo $c->getPageWrapperClass()?>">
<?php
	// ブロックを置けるエリアを作成
	$a = new Area('Area1');
	$a->display();
	// エリアを複数作る場合は、Area(引数); の引数を変更して作成
	$a = new Area('Area2');
	$a->display();
?>
</div>
<?php
	// concrete5 の動作に必要な、<body> タグ内コードを出力 </body> 直前に置くのがお作法らしい
	Loader::element('footer_required');
?>
</body>
</html>

このコードで、Area1 / Area2 としてブロックが配置できるテンプレートが利用可能になりました。
管理画面で、サムネイルも名前も説明も何も表示されないというような状況もありますが、この記事のコードをとっかかりに、今後、解決していきたいと思います。

参考

【完全保存版】 concrete5.6.x テーマスニペット集

5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?