Разработка сайта на CMS Craft CMS
Craft CMS — PHP/Yii-based CMS с кодом на GitHub, работающая на MySQL или PostgreSQL. Отличается гибкой системой полей, мощным шаблонизатором Twig, встроенными мультисайтовостью и локализацией. Занимает нишу между WordPress (слишком ограниченным для сложных структур) и полностью кастомными решениями.
Сильные стороны Craft CMS
Matrix Fields — блоки контента произвольной структуры внутри поля, аналог WordPress Gutenberg, но с кодом, а не UI-конструктором. Позволяет строить page builder без плагинов.
Sections — три типа: Channel (блог, новости), Structure (иерархия страниц), Single (одиночные страницы). Каждый Section имеет свои Entry Types с разными наборами полей.
Relations — нативные двусторонние связи между Entry любых типов.
Live Preview — редактор видит изменения в реальном времени в iframe с реальной страницей сайта.
Архитектура типового сайта
Sections:
├── Homepage (Single)
│ └── Entry Type: homepage
│ └── Fields: hero (Matrix), about (Matrix), stats (Table)
│
├── Services (Structure)
│ └── Entry Type: service
│ └── Fields: intro (Text), features (Matrix), cta (Object)
│
├── Blog (Channel)
│ ├── Entry Type: article
│ │ └── Fields: body (Matrix), author (Users), tags (Tags)
│ └── Entry Type: video
│ └── Fields: videoUrl (URL), transcript (Redactor)
│
└── Team (Channel)
└── Entry Type: teamMember
└── Fields: role (Text), bio (Redactor), photo (Assets)
Matrix Field — основа гибкой вёрстки
Matrix Field содержит блоки разных типов. Пример поля pageContent:
Block Types:
├── richText: body (Redactor)
├── imageBlock: image (Assets), caption (Text), alignment (Select)
├── codeBlock: code (Code), language (Select)
├── quote: text (Text), author (Text), role (Text)
├── cta: title (Text), text (Text), buttonLabel (Text), buttonUrl (URL)
└── gallery: images (Assets multiple), columns (Select 2/3/4)
В Twig-шаблоне:
{% for block in entry.pageContent.all() %}
{% switch block.type %}
{% case "richText" %}
<div class="prose">{{ block.body }}</div>
{% case "imageBlock" %}
<figure class="image-block align-{{ block.alignment }}">
{% set image = block.image.one() %}
{% if image %}
<img src="{{ image.getUrl('large') }}"
alt="{{ image.alt }}"
width="{{ image.width }}"
height="{{ image.height }}">
{% if block.caption %}
<figcaption>{{ block.caption }}</figcaption>
{% endif %}
{% endif %}
</figure>
{% case "cta" %}
<div class="cta-block">
<h3>{{ block.title }}</h3>
<p>{{ block.text }}</p>
<a href="{{ block.buttonUrl }}" class="btn">{{ block.buttonLabel }}</a>
</div>
{% case "gallery" %}
<div class="gallery cols-{{ block.columns }}">
{% for image in block.images.all() %}
<img src="{{ image.getUrl('medium') }}" alt="{{ image.alt }}">
{% endfor %}
</div>
{% endswitch %}
{% endfor %}
Запросы через ElementQuery
{# Последние посты с пагинацией #}
{% set query = craft.entries()
.section('blog')
.type('article')
.status('live')
.orderBy('postDate desc')
.limit(12) %}
{% set totalPosts = query.count() %}
{% set posts = query.offset(pageInfo.offset).all() %}
{% for post in posts %}
{% include '_components/post-card' with { post: post } %}
{% endfor %}
{% if pageInfo.totalPages > 1 %}
{% include '_components/pagination' %}
{% endif %}
Преобразования изображений
{# Трансформации — Named Transforms или inline #}
{% set transform = {
width: 1200,
height: 630,
mode: 'crop',
position: 'center-center',
format: 'webp',
quality: 85
} %}
<picture>
<source
srcset="{{ entry.heroImage.one().getUrl({ width: 800, format: 'webp' }) }} 800w,
{{ entry.heroImage.one().getUrl({ width: 1600, format: 'webp' }) }} 1600w"
type="image/webp">
<img
src="{{ entry.heroImage.one().getUrl(transform) }}"
alt="{{ entry.heroImage.one().alt }}"
loading="lazy">
</picture>
Plugins экосистема
| Плагин | Назначение |
|---|---|
| SEOmatic | SEO-мета, OpenGraph, Schema.org, Sitemap |
| Redactor | Rich text редактор |
| CKEditor | Альтернативный rich text |
| Feed Me | Импорт данных из RSS/XML/CSV |
| Commerce | Полноценный интернет-магазин |
| Formie | Конструктор форм |
| Blitz | Static caching (аналог Full Page Cache) |
| Vite | Vite-интеграция для ассетов |
Сроки разработки
| Этап | Время |
|---|---|
| Установка, настройка, структура секций | 1–2 дня |
| Content Model (поля, Matrix) | 2–3 дня |
| Twig-шаблоны | 3–7 дней |
| Плагины (SEO, формы, etc.) | 1–2 дня |
| Деплой + staging | 1 день |
| Корпоративный сайт (10–15 страниц) | 10–15 дней |
| Сложный портал | 4–8 недель |







