Skip to content

Commit 4a39b94

Browse files
committed
help added
1 parent 530f77c commit 4a39b94

4 files changed

Lines changed: 186 additions & 25 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<img src="{{ Model.banner.url }}"/>
2+
3+
{{ Page.Content }}
4+
5+
<table>
6+
<tr>
7+
<th>Title</th>
8+
<th>Price</th>
9+
</tr>
10+
{{# Page.Model.goods }}
11+
<tr>
12+
<td>{{ title }}</td>
13+
<td>{{ price }}</td>
14+
</tr>
15+
{{/ Page.Model.goods }}
16+
</table>

_help/src/Pages/folders-structure/pages.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,16 @@ The `title` attribute is not mandatory, but we recommend to use it for setting h
5454

5555
If predefined attributes are not enough and you want to add some extra attributes to your page, you can acheive that by using custom attributes section. The name of custom attribute should start with `custom` followed by `.`. After that you should add at least one character that will represent the name of your attribute.
5656

57+
> More advanced details about how to work with custom attributes can be found in [page custom attributes](/folders-structure/pages/attributes.html) section.
5758
58-
#### Page object
59+
### Data model
5960

60-
All attributes can be accessible through global `Page` object. That object is accessible from each and every template and it always has a context of current page.
61+
In case you want to use the same template, but use different data for it you can use page data model. The scenario here is to have different data (in terms of value) with the same structure on different pages. The name of page data model should start with `model` followed by `.`. After that you should add at least one character that will represent the name of your data model. The value of `model` should always point to valid `data` object.
6162

62-
You can access predefined page attributes via `Page.Title`, `Page.Url`, `Page.TemplateId` and `Page.Content` for page html content. All properties of global `Page` object are case sensitive.
63+
> More advanced details about how to work with data can be found in [page data model](/folders-structure/pages/model.html) section.
6364
64-
You can access custom page attributes via properties of `Page.Custom` object. It will have all the properties defibed in page metadata secrion.
65+
### Custom attributes vs data model
6566

66-
#### Example
67-
68-
If your page file looks like this:
69-
70-
```markdown
71-
url: index.html
72-
template: default.hjs
73-
title: Home
74-
75-
custom.header: header
76-
custom.description: this is my home page
77-
custom.logo.url: http://my.com/logo.png
78-
79-
---
80-
81-
# Welcome to my website!
82-
```
83-
84-
You can access logo url using the following statement `Page.Custom.logo.url`.
85-
86-
There is one important point to highlight here. `Page.Custom` is predifened and case sensitive, but `logo.url` was generated dynamicaly from page metadata and it's also case sensitive.
67+
The main difference between custom attributes and data model is how they interpreter the values you provide.
68+
- **Custom attributes** always threat all the values like strings.
69+
- **Data model** always threat all the values like reference to global `Data` model. It will copy all the values from referenced `Data` object to current `Model` object.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
url: folders-structure/pages/attributes.html
2+
template: default.hjs
3+
4+
title: Pages custom attributes
5+
6+
---
7+
8+
[back to pages folder structure](/folders-structure/pages.html)
9+
10+
### Custom attributes
11+
12+
If predefined attributes are not enough and you want to add some extra attributes to your page, you can acheive that by using custom attributes section. The name of custom attribute should start with `custom` followed by `.`. After that you should add at least one character that will represent the name of your attribute.
13+
14+
15+
#### Page object
16+
17+
All attributes can be accessible through global `Page` object. That object is accessible from each and every template and it always has a context of current page.
18+
19+
You can access predefined page attributes via `Page.Title`, `Page.Url`, `Page.TemplateId` and `Page.Content` for page html content. All properties of global `Page` object are case sensitive.
20+
21+
You can access custom page attributes via properties of `Page.Custom` object. It will have all the properties defined in page metadata section.
22+
23+
#### Example
24+
25+
If your page file looks like this:
26+
27+
```markdown
28+
url: index.html
29+
template: default.hjs
30+
title: Home
31+
32+
custom.header: header
33+
custom.description: this is my home page
34+
custom.logo.url: http://my.com/logo.png
35+
36+
---
37+
38+
# Welcome to my website!
39+
```
40+
41+
You can access logo url using the following statement `Page.Custom.logo.url`.
42+
43+
There is one important point to highlight here. `Page.Custom` is predifened and case sensitive, but `logo.url` was generated dynamicaly from page metadata and it's also case sensitive.
44+
45+
### Custom attributes vs data model
46+
47+
The main difference between custom attributes and data model is how they interpreter the values you provide.
48+
- **Custom attributes** always threat all the values like strings.
49+
- **Data model** always threat all the values like reference to global `Data` model. It will copy all the values from referenced `Data` object to current `Model` object.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
url: folders-structure/pages/model.html
2+
template: default.hjs
3+
4+
title: Pages data model
5+
6+
---
7+
8+
[back to pages folder structure](/folders-structure/pages.html)
9+
10+
### Data model
11+
12+
In case you want to use the same template, but use different data for it you can use page data model. The scenario here is to have different data (in terms of value) with the same structure on different pages. The name of page data model should start with `model` followed by `.`. After that you should add at least one character that will represent the name of your data model. The value of `model` should always point to valid `data` object.
13+
14+
15+
#### Page object
16+
17+
All data models can be accessible through global `Page` object. That object is accessible from each and every template and it always has a context of current page.
18+
19+
You can access page data models via properties of `Page.Model` object. It will have all the properties defined in page metadata section.
20+
21+
#### Example
22+
23+
If your template file looks like this:
24+
25+
```handlebars
26+
{{ Data.FoldersStructure.Pages.Model.Template01 }}
27+
```
28+
29+
And your page file looks like this:
30+
31+
```markdown
32+
url: goods1.html
33+
template: goods.hjs
34+
title: Home
35+
36+
model.goods: Data.category1.goods
37+
model.banner.url: Data.banners.banner1.url
38+
39+
---
40+
41+
# Category 1
42+
```
43+
44+
And your data structure looks like this:
45+
46+
```none
47+
Data
48+
category1.yml
49+
category2.yml
50+
banners.yml
51+
```
52+
53+
`category1.yml`
54+
```yaml
55+
goods:
56+
-
57+
title: apple
58+
price: 10
59+
-
60+
title: pear
61+
price: 12
62+
```
63+
64+
`category2.yml`
65+
```yaml
66+
goods:
67+
-
68+
title: potato
69+
price: 6
70+
-
71+
title: tomato
72+
price: 15
73+
```
74+
75+
`banners.yml`
76+
```yaml
77+
banner1:
78+
url: "http://mywebsite.com/banner1.png"
79+
banner2:
80+
url: "http://other.com/something.png"
81+
```
82+
83+
Finally, the html rendered by Solidify Engine will look like this:
84+
85+
```html
86+
<img src="http://mywebsite.com/banner1.png"/>
87+
88+
<h1>Category 1</h1>
89+
90+
<table>
91+
<tr>
92+
<th>Title</th>
93+
<th>Price</th>
94+
</tr>
95+
<tr>
96+
<td>apple</td>
97+
<td>10</td>
98+
</tr>
99+
<tr>
100+
<td>pear</td>
101+
<td>12</td>
102+
</tr>
103+
</table>
104+
```
105+
106+
107+
There is one important point to highlight here. `Page.Model` is predifened and case sensitive, but `goods` was generated dynamicaly from page metadata and it's also case sensitive.
108+
109+
### Custom attributes vs data model
110+
111+
The main difference between custom attributes and data model is how they interpreter the values you provide.
112+
- **Custom attributes** always threat all the values like strings.
113+
- **Data model** always threat all the values like reference to global `Data` model. It will copy all the values from referenced `Data` object to current `Model` object.

0 commit comments

Comments
 (0)