Skip to content

Commit

Permalink
Using new template controls in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Jun 27, 2012
1 parent 868d369 commit 45b2cbf
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 72 deletions.
4 changes: 2 additions & 2 deletions docs/en/howto/extend-cms-interface.md
Expand Up @@ -130,9 +130,9 @@ and replace it with the following:

:::ss
<ul>
<% control BookmarkedPages %>
<% loop BookmarkedPages %>
<li><a href="admin/page/edit/show/$ID">Edit "$Title"</a></li>
<% end_control %>
<% end_loop %>
</ul>

## Summary
Expand Down
16 changes: 8 additions & 8 deletions docs/en/howto/grouping-dataobjectsets.md
Expand Up @@ -74,14 +74,14 @@ In this case, the `getTitleFirstLetter()` method defined earlier is used to brea
:::ss
<%-- Modules list grouped by TitleFirstLetter --%>
<h2>Modules</h2>
<% control GroupedModules.GroupedBy(TitleFirstLetter) %>
<% loop GroupedModules.GroupedBy(TitleFirstLetter) %>
<h3>$TitleFirstLetter</h3>
<ul>
<% control Children %>
<% loop Children %>
<li>$Title</li>
<% end_control %>
<% end_loop %>
</ul>
<% end_control %>
<% end_loop %>

## Grouping Sets By Month

Expand Down Expand Up @@ -133,14 +133,14 @@ The final step is the render this into the template using the [api:GroupedList->
:::ss
// Modules list grouped by the Month Posted
<h2>Modules</h2>
<% control GroupedModulesByDate.GroupedBy(MonthCreated) %>
<% loop GroupedModulesByDate.GroupedBy(MonthCreated) %>
<h3>$MonthCreated</h3>
<ul>
<% control Children %>
<% loop Children %>
<li>$Title ($Created.Nice)</li>
<% end_control %>
<% end_loop %>
</ul>
<% end_control %>
<% end_loop %>

## Related

Expand Down
8 changes: 4 additions & 4 deletions docs/en/howto/pagination.md
Expand Up @@ -32,9 +32,9 @@ The first step is to simply list the objects in the template:

:::ss
<ul>
<% control PaginatedPages %>
<% loop PaginatedPages %>
<li><a href="$Link">$Title</a></li>
<% end_control %>
<% end_loop %>
</ul>

By default this will display 10 pages at a time. The next step is to add pagination
Expand All @@ -45,7 +45,7 @@ controls below this so the user can switch between pages:
<% if PaginatedPages.NotFirstPage %>
<a class="prev" href="$PaginatedPages.PrevLink">Prev</a>
<% end_if %>
<% control PaginatedPages.Pages %>
<% loop PaginatedPages.Pages %>
<% if CurrentBool %>
$PageNum
<% else %>
Expand All @@ -55,7 +55,7 @@ controls below this so the user can switch between pages:
...
<% end_if %>
<% end_if %>
<% end_control %>
<% end_loop %>
<% if PaginatedPages.NotLastPage %>
<a class="next" href="$PaginatedPages.NextLink">Next</a>
<% end_if %>
Expand Down
2 changes: 1 addition & 1 deletion docs/en/misc/coding-conventions.md
Expand Up @@ -420,7 +420,7 @@ Put code into the classes in the following order (where applicable).
* Commonly used methods like `getCMSFields()`
* Accessor methods (`getMyField()` and `setMyField()`)
* Controller action methods
* Template data-access methods (methods that will be called by a `$MethodName` or `<% control MethodName %>` construct in a template somewhere)
* Template data-access methods (methods that will be called by a `$MethodName` or `<% loop MethodName %>` construct in a template somewhere)
* Object methods

### SQL Format
Expand Down
12 changes: 6 additions & 6 deletions docs/en/reference/partial-caching.md
Expand Up @@ -23,7 +23,7 @@ The way you mark a section of the template as being cached is to wrap that secti


Each cache block has a cache key - an unlimited number of comma separated variables (in the same form as `if` and
`control` tag variables) and quoted strings.
`loop`/`with` tag variables) and quoted strings.

Every time the cache key returns a different result, the contents of the block are recalculated. If the cache key is the
same as a previous render, the cached value stored last time is used.
Expand Down Expand Up @@ -207,19 +207,19 @@ could also write the last example as:

## The important rule

Currently cached blocks can not be contained within if or control blocks. The template engine will throw an error
Currently cached blocks can not be contained within if or loop blocks. The template engine will throw an error
letting you know if you've done this. You can often get around this using aggregates.

Failing example:

:::ss
<% cached LastEdited %>

<% control Children %>
<% loop Children %>
<% cached LastEdited %>
$Name
<% end_cached %>
<% end_control %>
<% end_loop %>

<% end_cached %>

Expand All @@ -231,9 +231,9 @@ Can be re-written as:
<% cached LastEdited %>

<% cached Children.max(LastEdited) %>
<% control Children %>
<% loop Children %>
$Name
<% end_control %>
<% end_loop %>
<% end_cached %>

<% end_cached %>
10 changes: 5 additions & 5 deletions docs/en/reference/searchcontext.md
Expand Up @@ -141,9 +141,9 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
:::ss
<% if Results %>
<ul>
<% control Results %>
<li>$Titulo, $Autor</li>
<% end_control %>
<% loop Results %>
<li>$Title, $Autor</li>
<% end_loop %>
</ul>
<% else %>
<p>Sorry, your search query did not return any results.</p>
Expand All @@ -157,7 +157,7 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
<% end_if %>
<span>
<% control Results.PaginationSummary(4) %>
<% loop Results.PaginationSummary(4) %>
<% if CurrentBool %>
$PageNum
<% else %>
Expand All @@ -167,7 +167,7 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
&hellip;
<% end_if %>
<% end_if %>
<% end_control %>
<% end_loop %>
</span>
<% if Results.NotLastPage %>
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/siteconfig.md
Expand Up @@ -15,9 +15,9 @@ You can access `[api:SiteConfig]` options from any SS template by using the func

// or

<% control SiteConfig %>
<% loop SiteConfig %>
$Title $AnotherField
<% end_control %>
<% end_loop %>


Or if you want to access variables in the PHP you can do
Expand Down
4 changes: 2 additions & 2 deletions docs/en/topics/datamodel.md
Expand Up @@ -40,7 +40,7 @@ are `filter()` and `sort()`:

Those of you who know a bit about SQL might be thinking "it looks like you're querying all members, and then filtering
to those with a first name of 'Sam'. Isn't this very slow?" Is isn't, because the ORM doesn't actually execute the
query until you iterate on the result with a `foreach()` or `<% control %>`.
query until you iterate on the result with a `foreach()` or `<% loop %>`.

:::php
// The SQL query isn't executed here...
Expand Down Expand Up @@ -403,7 +403,7 @@ but using the *obj()*-method or accessing through a template will cast the value

// $myPlayer->MembershipFee() returns a float (e.g. 123.45)
// $myPlayer->obj('MembershipFee') returns a object of type Currency
// In a template: <% control MyPlayer %>MembershipFee.Nice<% end_control %> returns a casted string (e.g. "$123.45")
// In a template: <% loop MyPlayer %>MembershipFee.Nice<% end_loop %> returns a casted string (e.g. "$123.45")
public function getMembershipFee() {
return $this->Team()->BaseFee * $this->MembershipYears;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/en/topics/email.md
Expand Up @@ -34,7 +34,7 @@ The default HTML template is located in `framework/templates/email/GenericEmail.
### Templates

* Create a SS-template file called, in this example we will use 'MyEmail.ss' inside `mysite/templates/email`.
* Fill this out with the body text for your email. You can use any [SS-template syntax](/topics/templates) (e.g. `<% control %>`,
* Fill this out with the body text for your email. You can use any [SS-template syntax](/topics/templates) (e.g. `<% loop %>`,
`<% if %>`, $FirstName etc)
* Choose your template with **setTemplate()**
* Populate any custom data into the template before sending with **populateTemplate()**
Expand Down
4 changes: 2 additions & 2 deletions docs/en/topics/forms.md
Expand Up @@ -223,7 +223,7 @@ basic customisation:

<% if Actions %>
<div class="Actions">
<% control Actions %>$Field<% end_control %>
<% loop Actions %>$Field<% end_loop %>
</div>
<% end_if %>
</form>
Expand All @@ -234,7 +234,7 @@ for the type of field. Pass in the name of the field as the first parameter, as
template.

To find more methods, have a look at the `[api:Form]` class, as there is a lot of different methods of customising the form
templates, for example, you could use `<% control Fields %>` instead of specifying each field manually, as we've done
templates, for example, you could use `<% loop Fields %>` instead of specifying each field manually, as we've done
above.

### Custom form field templates
Expand Down
4 changes: 2 additions & 2 deletions docs/en/topics/javascript.md
Expand Up @@ -375,9 +375,9 @@ Template:

:::ss
<ul>
<% control Results %>
<% loop Results %>
<li id="Result-$ID">$Title</li>
<% end_control %>
<% end_loop %>
</ul>


Expand Down
4 changes: 2 additions & 2 deletions docs/en/topics/rich-text-editing.md
Expand Up @@ -121,10 +121,10 @@ of the CMS you have to take care of instanciation yourself:
:::ss
// File: mysite/templates/MyController.ss
$Form
<% control EditorToolbar %>
<% with EditorToolbar %>
$MediaForm
$LinkForm
<% end_control %>
<% end_with %>

Note: The dialogs rely on CMS-access, e.g. for uploading and browsing files,
so this is considered advanced usage of the field.
Expand Down
14 changes: 7 additions & 7 deletions docs/en/topics/theme-development.md
Expand Up @@ -74,9 +74,9 @@ our theme in action. The code for mine is below.
<div id="Navigation">
<% if Menu(1) %>
<ul>
<% control Menu(1) %>
<% loop Menu(1) %>
<li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
<% end_control %>
<% end_loop %>
</ul>
<% end_if %>
</div>
Expand Down Expand Up @@ -183,24 +183,24 @@ Next is a division for the main navigation. This may contain something like:
<div id="Navigation">
<% if Menu(1) %>
<ul>
<% control Menu(1) %>
<% loop Menu(1) %>
<li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
<% end_control %>
<% end_loop %>
</ul>
<% end_if %>
</div>


This is the standard for creating the main Navigation. As you can see it outputs the Menu 1 in a unordered list.

Before stepping into a control (a foreach loop) it's good practise to check if it exists first. This is not only
Before stepping into a loop it's good practise to check if it exists first. This is not only
important in manipulating SilverStripe templates, but in any programming language!

:::ss
<% if MyFunction %>
<% control MyFunction %>
<% loop MyFunction %>
$Title
<% end_control %>
<% end_loop %>
<% end_if %>


Expand Down
4 changes: 2 additions & 2 deletions docs/en/tutorials/3-forms.md
Expand Up @@ -388,12 +388,12 @@ The final step is to create the template to display our data. Change the 'Browse
$BrowserPollForm
<% else %>
<ul>
<% control BrowserPollResults %>
<% loop BrowserPollResults %>
<li>
<div class="browser">$Browser: $Percentage%</div>
<div class="bar" style="width:$Percentage%">&nbsp;</div>
</li>
<% end_control %>
<% end_loop %>
</ul>
<% end_if %>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/en/tutorials/4-site-search.md
Expand Up @@ -113,7 +113,7 @@ class.
<% if Results %>
<ul id="SearchResults">
<% control Results %>
<% loop Results %>
<li>
<a class="searchResultHeader" href="$Link">
<% if MenuTitle %>
Expand All @@ -127,7 +127,7 @@ class.
title="Read more about &quot;{$Title}&quot;"
>Read more about &quot;{$Title}&quot;...</a>
</li>
<% end_control %>
<% end_loop %>
</ul>
<% else %>
<p>Sorry, your search query did not return any results.</p>
Expand All @@ -142,13 +142,13 @@ class.
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
<% end_if %>
<span>
<% control Results.Pages %>
<% loop Results.Pages %>
<% if CurrentBool %>
$PageNum
<% else %>
<a href="$Link" title="View page number $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>
<% end_loop %>
</span>
<p>Page $Results.CurrentPage of $Results.TotalPages</p>
</div>
Expand Down

0 comments on commit 45b2cbf

Please sign in to comment.