Skip to content

Commit 786f56b

Browse files
committed
add snippets to cms docs
1 parent 7aadd4f commit 786f56b

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

src/app/user-manual/cms/page.mdx

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Link from 'next/link';
22
import Alert from '@/components/Alert';
3-
import { Paperclip, Wrench } from '@phosphor-icons/react/dist/ssr'
3+
import { FileCode, Paperclip, Wrench } from '@phosphor-icons/react/dist/ssr'
44

55

66
# Content Management System
@@ -9,12 +9,45 @@ The Content Management System, or CMS, is a powerful component that allows you t
99

1010
CMS consists of 3 sub-components. Pages, snippets and resources.
1111

12+
<Alert severity="warning">
13+
The content management system is still in its infancy.
14+
Although it is already an extremely flexible and powerful component, utilizing it to its full potential requires some basic web development skills.
15+
</Alert>
16+
1217
## Pages
1318

14-
Pages
19+
TBA
1520

1621
## Snippets
1722

23+
Snippets are small pieces of content that can be re-used, or more easily modified compared to entire pages.
24+
It's generally a good idea to turn static content into manage-able snippets.
25+
26+
### Managing snippets
27+
28+
Snippets can be managed from the admin panel. Found under <Wrench /> Settings -> <FileCode /> Snippets.
29+
30+
Currently there are 2 types of snippets.
31+
- **Rich Text**: Use a WYSIWYG rich text editor to enter content.
32+
- **Twig**: For raw Twig HTML code, requires some web development skill.
33+
34+
After saving a snippet, it will be given a slug. This slug is what you will need to use your snippet in pages or other snippets.
35+
36+
### Using snippets
37+
38+
You can use your snippets anywhere in Twig code, including CMS pages, or even nested in other snippets.
39+
40+
To use a snippet, use the `snippet('snippet-slug')` Twig function.
41+
42+
For example, if you created a snippet with the name "My Cool Snippet", the generated slug would be "my-cool-snippet".
43+
Then to use your snippet in a page:
44+
45+
```twig
46+
{% extends '@Forumify/frontend/page.html.twig' %}
47+
{% block body %}
48+
{{ snippet('my-cool-snippet') }}
49+
{% endblock %}
50+
```
1851

1952
## Resources
2053

@@ -28,29 +61,25 @@ Resources could be anything, images, downloads,...
2861
Resources can be uploaded from the admin panel, they can be found under <Wrench /> Settings -> <Paperclip /> Resources.
2962

3063
Simply supply a name and the file and press save. After saving your resource, it will be given a slug.
31-
Take note of it, **this is what you will need to use the resource** in pages and snippets.
64+
Take note of it, this is what you will need to use the resource in pages and snippets.
3265

3366
### Using resources
3467

35-
Resources can be used in pages and snippets using the `resource('resource-slug')` twig function
36-
37-
<Alert severityy="info">
38-
Currently it is only possible to use resources in Twig/Html pages and snippets. Rich text editor does not support them.
39-
</Alert>
68+
Resources can be used in pages and snippets using the `resource('resource-slug')` Twig function
4069

41-
### Examples
70+
#### Examples
4271

4372
For the following examples, we've created a resource named "My Cool Resource". The slug that was generated for it is "my-cool-resource".
4473

45-
#### Displaying an image
74+
##### Displaying an image
4675

4776
To display a resource as an image, use the `<img>` tag, with the resource in the `src` attribute.
4877

4978
```twig
5079
<img src="{{ resource('my-cool-resource') }}">
5180
```
5281

53-
#### Dowloading a file
82+
##### Dowloading a file
5483

5584
To make the client download a resource, you can use an `<a>` tag, with the resource in the `href` attribute and setting the `download` attribute.
5685

src/styles/index.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ ol, ul {
134134
display: flex;
135135
align-items: center;
136136
gap: var(--spacing-2);
137-
margin-top: var(--spacing-2);
138137

139138
svg {
140139
opacity: 0;

0 commit comments

Comments
 (0)