コンテンツにスキップ

テーマ構造

XOOPS テーマはサイトの視覚的なプレゼンテーションを制御します。テーマ構造を理解することは、カスタマイズおよび新しいテーマの作成に不可欠です。

themes/mytheme/
├── theme.html # メインレイアウトテンプレート
├── theme.ini # テーマ設定
├── theme_blockleft.html # 左サイドバーブロックテンプレート
├── theme_blockright.html # 右サイドバーブロックテンプレート
├── theme_blockcenter_c.html # センターブロック (中央)
├── theme_blockcenter_l.html # センターブロック (左揃え)
├── theme_blockcenter_r.html # センターブロック (右揃え)
├── css/
│ ├── style.css # メインスタイルシート
│ ├── admin.css # 管理カスタマイズ (オプション)
│ └── print.css # 印刷スタイルシート (オプション)
├── js/
│ └── theme.js # テーマ JavaScript
├── images/
│ ├── logo.png # サイトロゴ
│ └── icons/ # テーマアイコン
├── language/
│ └── english/
│ └── main.php # テーマ翻訳
├── modules/ # モジュールテンプレートオーバーライド
│ └── news/
│ └── news_index.tpl
└── screenshot.png # テーマプレビュー画像

すべてのコンテンツをラップするメインレイアウトテンプレート:

<!DOCTYPE html>
<html lang="<{$xoops_langcode}>">
<head>
<meta charset="<{$xoops_charset}>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><{$xoops_sitename}> - <{$xoops_pagetitle}></title>
<meta name="description" content="<{$xoops_meta_description}>">
<meta name="keywords" content="<{$xoops_meta_keywords}>">
{* Module-specific headers *}
<{$xoops_module_header}>
{* Theme stylesheets *}
<link rel="stylesheet" href="<{$xoops_url}>/themes/<{$xoops_theme}>/css/style.css">
</head>
<body class="<{$xoops_dirname}>">
<header class="site-header">
<a href="<{$xoops_url}>" class="logo">
<img src="<{$xoops_url}>/themes/<{$xoops_theme}>/images/logo.png"
alt="<{$xoops_sitename}>">
</a>
<nav class="main-nav">
<{$xoops_mainmenu}>
</nav>
</header>
<div class="page-container">
{* Left sidebar *}
<{if $xoops_showlblock == 1}>
<aside class="sidebar-left">
<{foreach item=block from=$xoops_lblocks}>
<{include file="theme:theme_blockleft.html"}>
<{/foreach}>
</aside>
<{/if}>
{* Main content *}
<main class="content">
<{$xoops_contents}>
</main>
{* Right sidebar *}
<{if $xoops_showrblock == 1}>
<aside class="sidebar-right">
<{foreach item=block from=$xoops_rblocks}>
<{include file="theme:theme_blockright.html"}>
<{/foreach}>
</aside>
<{/if}>
</div>
<footer class="site-footer">
<{$xoops_footer}>
</footer>
{* Module-specific footers *}
<{$xoops_module_footer}>
</body>
</html>

テーマ設定ファイル:

[Theme]
name = "My Theme"
version = "1.0.0"
author = "Your Name"
license = "GPL-2.0"
description = "A modern responsive theme"
[Screenshots]
screenshot = "screenshot.png"
[Options]
responsive = true
bootstrap = false
[Settings]
primary_color = "#3498db"
secondary_color = "#2c3e50"
{* theme_blockleft.html *}
<section class="block block-left" id="block-<{$block.id}>">
<{if $block.title}>
<h3 class="block-title"><{$block.title}></h3>
<{/if}>
<div class="block-content">
<{$block.content}>
</div>
</section>
変数説明
$xoops_sitenameサイト名
$xoops_urlサイト URL
$xoops_theme現在のテーマ名
$xoops_langcode言語コード
$xoops_charset文字エンコーディング
$xoops_pagetitleページタイトル
$xoops_dirname現在のモジュール名
変数説明
$xoops_isuserログイン中
$xoops_isadmin管理者権限
$xoops_useridユーザーID
$xoops_unameユーザー名
変数説明
$xoops_showlblock左ブロック表示
$xoops_showrblock右ブロック表示
$xoops_showcblockセンターブロック表示
$xoops_lblocks左ブロック配列
$xoops_rblocks右ブロック配列
$xoops_contentsメインページコンテンツ

モジュールテンプレートオーバーライド

Section titled “モジュールテンプレートオーバーライド”

モジュールテンプレートをオーバーライドするには、それらをテーマに配置します。

themes/mytheme/modules/
└── news/
├── news_index.tpl # ニュースモジュールのインデックスをオーバーライド
└── news_article.tpl # 記事表示をオーバーライド
css/style.css
/* === Variables === */
:root {
--primary-color: #3498db;
--text-color: #333;
--bg-color: #fff;
}
/* === Base === */
body {
font-family: system-ui, sans-serif;
color: var(--text-color);
background: var(--bg-color);
}
/* === Layout === */
.page-container {
display: grid;
grid-template-columns: 250px 1fr 250px;
gap: 20px;
max-width: 1200px;
margin: 0 auto;
}
/* === Components === */
.block {
margin-bottom: 20px;
padding: 15px;
background: #f5f5f5;
border-radius: 4px;
}
.block-title {
margin: 0 0 10px;
font-size: 1.1em;
}
/* === Responsive === */
@media (max-width: 768px) {
.page-container {
grid-template-columns: 1fr;
}
.sidebar-left,
.sidebar-right {
order: 2;
}
}
  • ../Templates/Smarty-Templating - テンプレート構文
  • Theme-Development - 完全なテーマガイド
  • CSS-Best-Practices - スタイリングガイドライン
  • ../../03-Module-Development/Block-Development - ブロック作成