mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
commit
e98b7edc3e
@ -50,7 +50,7 @@ text-based format.
|
|||||||
|
|
||||||
## Template file location
|
## Template file location
|
||||||
|
|
||||||
SilverStripe templates are plain text files that have `.ss` extension and located within the `templates` directory of
|
SilverStripe templates are plain text files that have an `.ss` extension and are located within the `templates` directory of
|
||||||
a module, theme, or your `app/` folder.
|
a module, theme, or your `app/` folder.
|
||||||
|
|
||||||
By default, templates will have the same name as the class they are used to render. So, your `Page` class will
|
By default, templates will have the same name as the class they are used to render. So, your `Page` class will
|
||||||
@ -272,7 +272,7 @@ include.
|
|||||||
|
|
||||||
## Looping Over Lists
|
## Looping Over Lists
|
||||||
|
|
||||||
The `<% loop %>` tag is used to iterate or loop over a collection of items such as [DataList](api:SilverStripe\ORM\DataList) or a [ArrayList](api:SilverStripe\ORM\ArrayList)
|
The `<% loop %>` tag is used to iterate or loop over a collection of items such as [DataList](api:SilverStripe\ORM\DataList) or an [ArrayList](api:SilverStripe\ORM\ArrayList)
|
||||||
collection.
|
collection.
|
||||||
|
|
||||||
```ss
|
```ss
|
||||||
@ -288,7 +288,7 @@ This snippet loops over the children of a page, and generates an unordered list
|
|||||||
page.
|
page.
|
||||||
|
|
||||||
[notice]
|
[notice]
|
||||||
$Title inside the loop refers to the Title property on each object that is looped over, not the current page like
|
The `$Title` inside the loop refers to the Title property on each object that is looped over, not the current page like
|
||||||
the reference of `$Title` outside the loop.
|
the reference of `$Title` outside the loop.
|
||||||
|
|
||||||
This demonstrates the concept of [Scope](#scope). When inside a <% loop %> the scope of the template has changed to the
|
This demonstrates the concept of [Scope](#scope). When inside a <% loop %> the scope of the template has changed to the
|
||||||
@ -386,7 +386,7 @@ pagination.
|
|||||||
|
|
||||||
### Modulus and MultipleOf
|
### Modulus and MultipleOf
|
||||||
|
|
||||||
$Modulus and $MultipleOf can help to build column and grid layouts.
|
`$Modulus` and `$MultipleOf` can help to build column and grid layouts.
|
||||||
|
|
||||||
```ss
|
```ss
|
||||||
// returns an int
|
// returns an int
|
||||||
@ -409,7 +409,7 @@ $MultipleOf(factor, offset)
|
|||||||
`clear: both` to `.column-1`.
|
`clear: both` to `.column-1`.
|
||||||
[/hint]
|
[/hint]
|
||||||
|
|
||||||
$MultipleOf(value, offset) can also be utilized to build column and grid layouts. In this case we want to add a `<br>`
|
`$MultipleOf(value, offset)` can also be utilized to build column and grid layouts. In this case we want to add a `<br>`
|
||||||
after every 3rd item.
|
after every 3rd item.
|
||||||
|
|
||||||
```ss
|
```ss
|
||||||
@ -450,7 +450,7 @@ For more information on formatting and casting variables see [Formating, Modifyi
|
|||||||
## Scope
|
## Scope
|
||||||
|
|
||||||
In the `<% loop %>` section, we saw an example of two **scopes**. Outside the `<% loop %>...<% end_loop %>`, we were in
|
In the `<% loop %>` section, we saw an example of two **scopes**. Outside the `<% loop %>...<% end_loop %>`, we were in
|
||||||
the scope of the top level `Page`. But inside the loop, we were in the scope of an item in the list (i.e the `Child`)
|
the scope of the top level `Page`. But inside the loop, we were in the scope of an item in the list (i.e the `Child`).
|
||||||
|
|
||||||
The scope determines where the value comes from when you refer to a variable. Typically the outer scope of a `Page.ss`
|
The scope determines where the value comes from when you refer to a variable. Typically the outer scope of a `Page.ss`
|
||||||
layout template is the [PageController](api:SilverStripe\CMS\Controllers\ContentController\PageController) that is currently being rendered.
|
layout template is the [PageController](api:SilverStripe\CMS\Controllers\ContentController\PageController) that is currently being rendered.
|
||||||
|
Loading…
Reference in New Issue
Block a user