You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Templating.md
+160-8Lines changed: 160 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
-
# Templating in InspireCMS
1
+
# Templating
2
2
3
3
InspireCMS templates allow you to define reusable layouts and components for your content.
4
4
5
5
## Theme Management
6
-
7
6
### Creating a Theme
8
7
1. Navigate to `/cms/settings/templates`
9
8
2. Click `Create theme` or `Clone theme`
@@ -15,16 +14,18 @@ InspireCMS templates allow you to define reusable layouts and components for you
15
14
2. Click `Change theme`
16
15
3. Select your desired theme
17
16
18
-
> [!NOTE]
17
+
> [!TIP]
19
18
> You can view the current theme by running `php artisan inspirecms:about`
20
19
21
20
## Template Creation
22
21
23
22
1. Navigate to `/cms/settings/document-types`
24
-
2. Select your target **Document Type**
25
-
3. Create or edit an existing template for that **Document Type**
23
+
2. Select your target document type[^1]
24
+
3. Create or edit an existing template for that document type[^1]
25
+
26
+
InspireCMS uses [Blade](https://laravel.com/docs/11.x/blade) and automatically binds `$content` and `$locale`.
26
27
27
-
InspireCMS uses [Blade](https://laravel.com/docs/11.x/blade) and automatically binds `$content`. Example:
28
+
Example:
28
29
29
30
```php
30
31
@php
@@ -36,9 +37,159 @@ InspireCMS uses [Blade](https://laravel.com/docs/11.x/blade) and automatically b
36
37
</x-cms-template>
37
38
```
38
39
40
+
## Adding Fields to Template
41
+
42
+
InspireCMS allows you to add custom fields to your templates that content editors can use to populate pages.
43
+
44
+
### Defining Template Fields
45
+
46
+
When creating or editing a template, you can define fields in the "Fields" section:
47
+
48
+
1. Navigate to `/cms/settings/document-types`
49
+
2. Select your document type[^1]
50
+
3. Add fields using the form to input all required form group data, e.g.
51
+
- Define field name, label, type, and validation rules
52
+
- Organize fields into logical groups if needed
53
+
- Set default values and configuration options
54
+
- etc.
55
+
56
+
### Field Types
57
+
58
+
For detailed information about available field types and their configuration options, please see the [Custom Fields documentation](./docs/CustomFields.md).
59
+
60
+
### Using Fields in Templates
61
+
62
+
InspireCMS provides several directives to access your field data:
63
+
-`@property()` - For basic field access
64
+
-`@propertyArray()` - For accessing array fields (repeaters, content pickers, etc.)
65
+
-`@propertyNotEmpty()` - For conditional rendering based on field content
66
+
67
+
#### Access Patterns
68
+
69
+
Fields can be accessed using different patterns depending on your needs:
<!-- Value is from $blogDTO, variable available as $post_writer -->
102
+
```
103
+
104
+
105
+
#### Field Type-Specific Notes
106
+
107
+
Different field types return different data structures:
108
+
-**Repeater**: Return arrays that can be iterated with `@foreach` directive
109
+
-**Content Picker**: Return array of objects with methods like `getUrl()` and `getTitle()`
110
+
-**File/Image**: Return associative arrays with metadata like 'disk', 'path', 'directory', etc.
111
+
-**Rich Text**: Return rendered HTML content
112
+
113
+
> [!NOTE]
114
+
> For detailed information about specific field types and their access patterns, please refer to the [Custom Fields documentation](docs/CustomFields.md).
115
+
116
+
#### Example
117
+
118
+
1. Basic Field Access
119
+
120
+
```php
121
+
<h1>@property('hero', 'title')</h1>
122
+
123
+
<p>@property('hero', 'subtitle')</p>
124
+
125
+
@propertyArray('document_content', 'categories')
126
+
<!-- Loop through array items -->
127
+
@foreach ($blog_content_categories ?? [] as $category)
Let's assume you've created a theme named "**abc**".
42
193
43
194
### Approach 1: Using Components
44
195
@@ -281,6 +432,7 @@ Learn more about [layouts using inheritance in Blade](https://laravel.com/docs/1
281
432
@endsection
282
433
```
283
434
284
-
## Adding Fields to Template
435
+
[^1]: Document types define the structure and behavior of content in InspireCMS. For detailed information, see the [Document Type](../docs/docs/references/DocumentType.md).
0 commit comments