Consistently used dollar notation in template docs (see #1794)

This commit is contained in:
Ingo Schommer 2013-04-26 11:48:59 +02:00
parent b211f22bf9
commit 5f91c3724d
22 changed files with 94 additions and 94 deletions

View File

@ -129,7 +129,7 @@ and replace it with the following:
:::ss :::ss
<ul> <ul>
<% loop BookmarkedPages %> <% loop $BookmarkedPages %>
<li><a href="admin/pages/edit/show/$ID">Edit "$Title"</a></li> <li><a href="admin/pages/edit/show/$ID">Edit "$Title"</a></li>
<% end_loop %> <% end_loop %>
</ul> </ul>

View File

@ -74,10 +74,10 @@ In this case, the `getTitleFirstLetter()` method defined earlier is used to brea
:::ss :::ss
<%-- Modules list grouped by TitleFirstLetter --%> <%-- Modules list grouped by TitleFirstLetter --%>
<h2>Modules</h2> <h2>Modules</h2>
<% loop GroupedModules.GroupedBy(TitleFirstLetter) %> <% loop $GroupedModules.GroupedBy(TitleFirstLetter) %>
<h3>$TitleFirstLetter</h3> <h3>$TitleFirstLetter</h3>
<ul> <ul>
<% loop Children %> <% loop $Children %>
<li>$Title</li> <li>$Title</li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -133,10 +133,10 @@ The final step is the render this into the template using the [api:GroupedList->
:::ss :::ss
// Modules list grouped by the Month Posted // Modules list grouped by the Month Posted
<h2>Modules</h2> <h2>Modules</h2>
<% loop GroupedModulesByDate.GroupedBy(MonthCreated) %> <% loop $GroupedModulesByDate.GroupedBy(MonthCreated) %>
<h3>$MonthCreated</h3> <h3>$MonthCreated</h3>
<ul> <ul>
<% loop Children %> <% loop $Children %>
<li>$Title ($Created.Nice)</li> <li>$Title ($Created.Nice)</li>
<% end_loop %> <% end_loop %>
</ul> </ul>

View File

@ -9,7 +9,7 @@ located in `themes/<mytheme>/templates/Page.ss`.
:::ss :::ss
<ul> <ul>
<% loop Menu(1) %> <% loop $Menu(1) %>
<li> <li>
<a href="$Link" title="Go to the $Title page" class="$LinkingMode"> <a href="$Link" title="Go to the $Title page" class="$LinkingMode">
<span>$MenuTitle</span> <span>$MenuTitle</span>

View File

@ -36,7 +36,7 @@ The first step is to simply list the objects in the template:
:::ss :::ss
<ul> <ul>
<% loop PaginatedPages %> <% loop $PaginatedPages %>
<li><a href="$Link">$Title</a></li> <li><a href="$Link">$Title</a></li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -45,22 +45,22 @@ By default this will display 10 pages at a time. The next step is to add paginat
controls below this so the user can switch between pages: controls below this so the user can switch between pages:
:::ss :::ss
<% if PaginatedPages.MoreThanOnePage %> <% if $PaginatedPages.MoreThanOnePage %>
<% if PaginatedPages.NotFirstPage %> <% if $PaginatedPages.NotFirstPage %>
<a class="prev" href="$PaginatedPages.PrevLink">Prev</a> <a class="prev" href="$PaginatedPages.PrevLink">Prev</a>
<% end_if %> <% end_if %>
<% loop PaginatedPages.Pages %> <% loop $PaginatedPages.Pages %>
<% if CurrentBool %> <% if $CurrentBool %>
$PageNum $PageNum
<% else %> <% else %>
<% if Link %> <% if $Link %>
<a href="$Link">$PageNum</a> <a href="$Link">$PageNum</a>
<% else %> <% else %>
... ...
<% end_if %> <% end_if %>
<% end_if %> <% end_if %>
<% end_loop %> <% end_loop %>
<% if PaginatedPages.NotLastPage %> <% if $PaginatedPages.NotLastPage %>
<a class="next" href="$PaginatedPages.NextLink">Next</a> <a class="next" href="$PaginatedPages.NextLink">Next</a>
<% end_if %> <% end_if %>
<% end_if %> <% end_if %>

View File

@ -427,7 +427,7 @@ Put code into the classes in the following order (where applicable).
* Commonly used methods like `getCMSFields()` * Commonly used methods like `getCMSFields()`
* Accessor methods (`getMyField()` and `setMyField()`) * Accessor methods (`getMyField()` and `setMyField()`)
* Controller action methods * Controller action methods
* Template data-access methods (methods that will be called by a `$MethodName` or `<% loop 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 * Object methods
### SQL Format ### SQL Format

View File

@ -215,7 +215,7 @@ Failing example:
:::ss :::ss
<% cached LastEdited %> <% cached LastEdited %>
<% loop Children %> <% loop $Children %>
<% cached LastEdited %> <% cached LastEdited %>
$Name $Name
<% end_cached %> <% end_cached %>
@ -231,7 +231,7 @@ Can be re-written as:
<% cached LastEdited %> <% cached LastEdited %>
<% cached Children.max(LastEdited) %> <% cached Children.max(LastEdited) %>
<% loop Children %> <% loop $Children %>
$Name $Name
<% end_loop %> <% end_loop %>
<% end_cached %> <% end_cached %>

View File

@ -139,9 +139,9 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
:::ss :::ss
<% if Results %> <% if $Results %>
<ul> <ul>
<% loop Results %> <% loop $Results %>
<li>$Title, $Autor</li> <li>$Title, $Autor</li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -149,19 +149,19 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
<p>Sorry, your search query did not return any results.</p> <p>Sorry, your search query did not return any results.</p>
<% end_if %> <% end_if %>
<% if Results.MoreThanOnePage %> <% if $Results.MoreThanOnePage %>
<div id="PageNumbers"> <div id="PageNumbers">
<p> <p>
<% if Results.NotFirstPage %> <% if $Results.NotFirstPage %>
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a> <a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
<% end_if %> <% end_if %>
<span> <span>
<% loop Results.PaginationSummary(4) %> <% loop $Results.PaginationSummary(4) %>
<% if CurrentBool %> <% if $CurrentBool %>
$PageNum $PageNum
<% else %> <% else %>
<% if Link %> <% if $Link %>
<a href="$Link" title="View page number $PageNum">$PageNum</a> <a href="$Link" title="View page number $PageNum">$PageNum</a>
<% else %> <% else %>
&hellip; &hellip;
@ -170,7 +170,7 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
<% end_loop %> <% end_loop %>
</span> </span>
<% if Results.NotLastPage %> <% if $Results.NotLastPage %>
<a class="next" href="$Results.NextLink" title="View the next page">Next</a> <a class="next" href="$Results.NextLink" title="View the next page">Next</a>
<% end_if %> <% end_if %>
</p> </p>

View File

@ -15,7 +15,7 @@ You can access `[api:SiteConfig]` options from any SS template by using the func
// or // or
<% loop SiteConfig %> <% loop $SiteConfig %>
$Title $AnotherField $Title $AnotherField
<% end_loop %> <% end_loop %>

View File

@ -4,9 +4,9 @@ These are the main changes to the SiverStripe 3 template language.
## Control blocks: Loops vs. Scope ## Control blocks: Loops vs. Scope
The `<% control var %>...<% end_control %>` in SilverStripe prior to version 3 has two different meanings. Firstly, if the control variable is a collection (e.g. DataList), then `<% control %>` iterates over that set. If it's a non-iteratable object, however, `<% control %>` introduces a new scope, which is used to render the inner template code. This dual-use is confusing to some people, and doesn't allow a collection of objects to be used as a scope. The `<% control $var %>...<% end_control %>` in SilverStripe prior to version 3 has two different meanings. Firstly, if the control variable is a collection (e.g. DataList), then `<% control %>` iterates over that set. If it's a non-iteratable object, however, `<% control %>` introduces a new scope, which is used to render the inner template code. This dual-use is confusing to some people, and doesn't allow a collection of objects to be used as a scope.
In SilverStripe 3, the first usage (iteration) is replaced by `<% loop var %>`. The second usage (scoping) is replaced by `<% with var %>` In SilverStripe 3, the first usage (iteration) is replaced by `<% loop $var %>`. The second usage (scoping) is replaced by `<% with $var %>`
## Literals in Expressions ## Literals in Expressions

View File

@ -26,9 +26,9 @@ Here is a very simple template:
<p>Welcome $FirstName $Surname.</p> <p>Welcome $FirstName $Surname.</p>
<% end_with %> <% end_with %>
<% if Dishes %> <% if $Dishes %>
<ul> <ul>
<% loop Dishes %> <% loop $Dishes %>
<li>$Title ($Price.Nice)</li> <li>$Title ($Price.Nice)</li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -106,7 +106,7 @@ The "include" tag can be particularly helpful for nested functionality. In this
a variable is true a variable is true
:::ss :::ss
<% if CurrentMember %> <% if $CurrentMember %>
<% include MembersOnlyInclude %> <% include MembersOnlyInclude %>
<% end_if %> <% end_if %>
@ -114,7 +114,7 @@ Includes can't directly access the parent scope of the scope active when the inc
pass arguments to the include, which are available on the scope top within the include pass arguments to the include, which are available on the scope top within the include
:::ss :::ss
<% with CurrentMember %> <% with $CurrentMember %>
<% include MemberDetails PageTitle=$Top.Title, PageID=$Top.ID %> <% include MemberDetails PageTitle=$Top.Title, PageID=$Top.ID %>
<% end_with %> <% end_with %>
@ -182,7 +182,7 @@ the markup in the `else` clause is used, if that clause is present.
This example shows the use of `not` to negate the test. This example shows the use of `not` to negate the test.
:::ss :::ss
<% if not $DinnerInOven %> <% if $not $DinnerInOven %>
I'm going out for dinner tonight. I'm going out for dinner tonight.
<% end_if %> <% end_if %>
@ -309,7 +309,7 @@ this case we want to add a <br> after every 3th item.
:::ss :::ss
<% loop $Children %> <% loop $Children %>
<% if MultipleOf(3) %> <% if $MultipleOf(3) %>
<br> <br>
<% end_if %> <% end_if %>
<% end_loop %> <% end_loop %>
@ -502,11 +502,11 @@ It renders in the template as `<base href="http://www.mydomain.com" /><!--[if lt
Returns the currently logged in member, if there is one. Returns the currently logged in member, if there is one.
All of their details or any special Member page controls can be called on this. All of their details or any special Member page controls can be called on this.
Alternately, you can use `<% if CurrentMember %>` to detect whether someone has logged Alternately, you can use `<% if $CurrentMember %>` to detect whether someone has logged
in. in.
:::ss :::ss
<% if CurrentMember %> <% if $CurrentMember %>
Welcome Back, $CurrentMember.FirstName Welcome Back, $CurrentMember.FirstName
<% end_if %> <% end_if %>
@ -541,7 +541,7 @@ Your function could return a single value as above or it could be a subclass of
And now you could call these values by using And now you could call these values by using
:::ss :::ss
<% with MyCustomValues %> <% with $MyCustomValues %>
$Hi , $Name $Hi , $Name
<% end_with %> <% end_with %>
// output "Kia Ora , John Smith" // output "Kia Ora , John Smith"

View File

@ -79,7 +79,7 @@ In templates, casting helpers are available without the need for an `obj()` call
Example: Flagging an object of type `MyObject` (see above) if it's date is in the past. Example: Flagging an object of type `MyObject` (see above) if it's date is in the past.
:::ss :::ss
<% if MyObjectInstance.MyDate.InPast %>Outdated!<% end_if %> <% if $MyObjectInstance.MyDate.InPast %>Outdated!<% end_if %>
## Casting HTML Text ## Casting HTML Text

View File

@ -393,7 +393,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->MembershipFee() returns a float (e.g. 123.45)
// $myPlayer->obj('MembershipFee') returns a object of type Currency // $myPlayer->obj('MembershipFee') returns a object of type Currency
// In a template: <% loop MyPlayer %>MembershipFee.Nice<% end_loop %> 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() { public function getMembershipFee() {
return $this->Team()->BaseFee * $this->MembershipYears; return $this->Team()->BaseFee * $this->MembershipYears;
} }

View File

@ -264,7 +264,7 @@ basic customisation:
:::ss :::ss
<form $FormAttributes> <form $FormAttributes>
<% if Message %> <% if $Message %>
<p id="{$FormName}_error" class="message $MessageType">$Message</p> <p id="{$FormName}_error" class="message $MessageType">$Message</p>
<% else %> <% else %>
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p> <p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
@ -284,9 +284,9 @@ basic customisation:
$Fields.dataFieldByName(SecurityID) $Fields.dataFieldByName(SecurityID)
</fieldset> </fieldset>
<% if Actions %> <% if $Actions %>
<div class="Actions"> <div class="Actions">
<% loop Actions %>$Field<% end_loop %> <% loop $Actions %>$Field<% end_loop %>
</div> </div>
<% end_if %> <% end_if %>
</form> </form>
@ -297,7 +297,7 @@ for the type of field. Pass in the name of the field as the first parameter, as
template. template.
To find more methods, have a look at the `[api:Form]` class and `[api:FieldList]` class as there is a lot of different To find more methods, have a look at the `[api:Form]` class and `[api:FieldList]` class as there is a lot of different
methods of customising the form templates. An example is that you could use `<% loop Fields %>` instead of specifying methods of customising the form templates. An example is that you could use `<% loop $Fields %>` instead of specifying
each field manually, as we've done above. each field manually, as we've done above.
### Custom form field templates ### Custom form field templates

View File

@ -378,7 +378,7 @@ Template:
:::ss :::ss
<ul> <ul>
<% loop Results %> <% loop $Results %>
<li id="Result-$ID">$Title</li> <li id="Result-$ID">$Title</li>
<% end_loop %> <% end_loop %>
</ul> </ul>

View File

@ -95,15 +95,15 @@ Note that pages with the `ShowInMenus` property set to FALSE will be filtered ou
### Children Loops ### Children Loops
:::ss :::ss
<% loop Children %>...<% end_loop %> <% loop $Children %>...<% end_loop %>
Will loop over all children of the current page context. Will loop over all children of the current page context.
Helpful to create page-specific subnavigations. Helpful to create page-specific subnavigations.
Most likely, you'll want to use `<% loop Menu %>` for your main menus, Most likely, you'll want to use `<% loop $Menu %>` for your main menus,
since its independent of the page context. since its independent of the page context.
:::ss :::ss
<% loop ChildrenOf(<my-page-url>) %>...<% end_loop %> <% loop $ChildrenOf(<my-page-url>) %>...<% end_loop %>
Will create a list of the children of the given page, Will create a list of the children of the given page,
as identified by its `URLSegment` value. This can come in handy because its not dependent as identified by its `URLSegment` value. This can come in handy because its not dependent
@ -111,7 +111,7 @@ on the context of the current page. For example, it would allow you to list all
underneath a "staff" holder on any page, regardless if its on the top level or elsewhere. underneath a "staff" holder on any page, regardless if its on the top level or elsewhere.
:::ss :::ss
<% loop allChildren %>...<% end_loop %> <% loop $allChildren %>...<% end_loop %>
This will show all children of a page even if the `ShowInMenus` property is set to FALSE. This will show all children of a page even if the `ShowInMenus` property is set to FALSE.
@ -137,7 +137,7 @@ To simply retrieve the parent page of the current context (if existing), use the
### Access to a specific Page ### Access to a specific Page
:::ss :::ss
<% loop Page(my-page) %>...<% end_loop %>` <% loop $Page(my-page) %>...<% end_loop %>`
"Page" will return a single page from the site tree, looking it up by URL. You can use it in the `<% loop %>` format. "Page" will return a single page from the site tree, looking it up by URL. You can use it in the `<% loop %>` format.
Can't be called using `$Page(my-page).Title`. Can't be called using `$Page(my-page).Title`.
@ -180,7 +180,7 @@ More common uses:
Example: Only show the menu item linked if its the current one: Example: Only show the menu item linked if its the current one:
:::ss :::ss
<% if LinkOrCurrent = current %> <% if $LinkOrCurrent = current %>
$Title $Title
<% else %> <% else %>
<a href="$Link">$Title</a> <a href="$Link">$Title</a>
@ -199,9 +199,9 @@ Simply place a file with the same name in your `themes/<your-theme>/templates`
folder to customize its output. Here's the default template: folder to customize its output. Here's the default template:
:::ss :::ss
<% if Pages %> <% if $Pages %>
<% loop Pages %> <% loop $Pages %>
<% if Last %>$Title.XML<% else %><a href="$Link">$MenuTitle.XML</a> &raquo;<% end_if %> <% if $Last %>$Title.XML<% else %><a href="$Link">$MenuTitle.XML</a> &raquo;<% end_if %>
<% end_loop %> <% end_loop %>
<% end_if %> <% end_if %>

View File

@ -121,7 +121,7 @@ of the CMS you have to take care of instanciation yourself:
:::ss :::ss
// File: mysite/templates/MyController.ss // File: mysite/templates/MyController.ss
$Form $Form
<% with EditorToolbar %> <% with $EditorToolbar %>
$MediaForm $MediaForm
$LinkForm $LinkForm
<% end_with %> <% end_with %>

View File

@ -72,9 +72,9 @@ our theme in action. The code for mine is below.
</div> </div>
<div id="Navigation"> <div id="Navigation">
<% if Menu(1) %> <% if $Menu(1) %>
<ul> <ul>
<% loop Menu(1) %> <% loop $Menu(1) %>
<li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li> <li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -180,9 +180,9 @@ Next is a division for the main navigation. This may contain something like:
:::ss :::ss
<div id="Navigation"> <div id="Navigation">
<% if Menu(1) %> <% if $Menu(1) %>
<ul> <ul>
<% loop Menu(1) %> <% loop $Menu(1) %>
<li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li> <li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -196,8 +196,8 @@ Before stepping into a loop it's good practise to check if it exists first. This
important in manipulating SilverStripe templates, but in any programming language! important in manipulating SilverStripe templates, but in any programming language!
:::ss :::ss
<% if MyFunction %> <% if $MyFunction %>
<% loop MyFunction %> <% loop $MyFunction %>
$Title $Title
<% end_loop %> <% end_loop %>
<% end_if %> <% end_if %>

View File

@ -158,7 +158,7 @@ Open up *themes/simple/templates/Includes/Navigation.ss*
The Menu for our site is created using a **loop**. Loops allow us to iterate over a data set, and render each item using a sub-template. The Menu for our site is created using a **loop**. Loops allow us to iterate over a data set, and render each item using a sub-template.
:::ss :::ss
<% loop Menu(1) %> <% loop $Menu(1) %>
returns a set of first level menu items. We can then use the template variable returns a set of first level menu items. We can then use the template variable
*$MenuTitle* to show the title of the page we are linking to, *$Link* for the URL of the page and *$LinkingMode* to help style our menu with CSS (explained in more detail shortly). *$MenuTitle* to show the title of the page we are linking to, *$Link* for the URL of the page and *$LinkingMode* to help style our menu with CSS (explained in more detail shortly).
@ -168,7 +168,7 @@ returns a set of first level menu items. We can then use the template variable
:::ss :::ss
<ul> <ul>
<% loop Menu(1) %> <% loop $Menu(1) %>
<li class="$LinkingMode"> <li class="$LinkingMode">
<a href="$Link" title="$Title.XML">$MenuTitle.XML</a> <a href="$Link" title="$Title.XML">$MenuTitle.XML</a>
</li> </li>
@ -225,7 +225,7 @@ Adding a second level menu is very similar to adding the first level menu. Open
:::ss :::ss
<ul> <ul>
<% loop Menu(2) %> <% loop $Menu(2) %>
<li class="$LinkingMode"> <li class="$LinkingMode">
<a href="$Link" title="Go to the $Title.XML page"> <a href="$Link" title="Go to the $Title.XML page">
<span class="arrow">&rarr;</span> <span class="arrow">&rarr;</span>
@ -245,10 +245,10 @@ Look again in the *Sidebar.ss* file and you will see that the menu is surrounded
like this: like this:
:::ss :::ss
<% if Menu(2) %> <% if $Menu(2) %>
... ...
<ul> <ul>
<% loop Menu(2) %> <% loop $Menu(2) %>
<li class="$LinkingMode"> <li class="$LinkingMode">
<a href="$Link" title="Go to the $Title.XML page"> <a href="$Link" title="Go to the $Title.XML page">
<span class="arrow">&rarr;</span> <span class="arrow">&rarr;</span>
@ -269,7 +269,7 @@ Now that we have two levels of navigation, it would also be useful to include so
Open up */themes/simple/templates/Includes/BreadCrumbs.ss* template and look at the following code: Open up */themes/simple/templates/Includes/BreadCrumbs.ss* template and look at the following code:
:::ss :::ss
<% if Level(2) %> <% if $Level(2) %>
<div id="Breadcrumbs"> <div id="Breadcrumbs">
$Breadcrumbs $Breadcrumbs
</div> </div>
@ -295,12 +295,12 @@ The following example runs an if statement, and a loop on *Children*, checking t
:::ss :::ss
<ul> <ul>
<% loop Menu(1) %> <% loop $Menu(1) %>
<li class="$LinkingMode"> <li class="$LinkingMode">
<a href="$Link" title="$Title.XML">$MenuTitle.XML</a> <a href="$Link" title="$Title.XML">$MenuTitle.XML</a>
<% if Children %> <% if $Children %>
<ul> <ul>
<% loop Children %> <% loop $Children %>
<li class="$LinkingMode"> <li class="$LinkingMode">
<a href="$Link" title="Go to the $Title.XML page"> <a href="$Link" title="Go to the $Title.XML page">
<span class="arrow">&rarr;</span> <span class="arrow">&rarr;</span>

View File

@ -285,7 +285,7 @@ We'll now create a template for the article holder. We want our news section to
$Content $Content
<div class="content">$Content</div> <div class="content">$Content</div>
</article> </article>
<% loop Children %> <% loop $Children %>
<article> <article>
<h2><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></h2> <h2><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></h2>
<p>$Content.FirstParagraph</p> <p>$Content.FirstParagraph</p>
@ -313,7 +313,7 @@ Cut the code between "loop Children" in *ArticleHolder.ss** and replace it with
:::ss :::ss
... ...
<% loop Children %> <% loop $Children %>
<% include ArticleTeaser %> <% include ArticleTeaser %>
<% end_loop %> <% end_loop %>
... ...
@ -370,7 +370,7 @@ This function simply runs a database query that gets the latest news articles fr
<!-- ... --> <!-- ... -->
<div class="content">$Content</div> <div class="content">$Content</div>
</article> </article>
<% loop LatestNews %> <% loop $LatestNews %>
<% include ArticleTeaser %> <% include ArticleTeaser %>
<% end_loop %> <% end_loop %>
@ -489,7 +489,7 @@ The staff section templates aren't too difficult to create, thanks to the utilit
$Content $Content
<div class="content">$Content</div> <div class="content">$Content</div>
</article> </article>
<% loop Children %> <% loop $Children %>
<article> <article>
<h2><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></h2> <h2><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></h2>
$Photo.SetWidth(150) $Photo.SetWidth(150)

View File

@ -325,11 +325,11 @@ The final step is to create the template to display our data. Change the 'Browse
:::ss :::ss
<div id="BrowserPoll"> <div id="BrowserPoll">
<h2>Browser Poll</h2> <h2>Browser Poll</h2>
<% if BrowserPollForm %> <% if $BrowserPollForm %>
$BrowserPollForm $BrowserPollForm
<% else %> <% else %>
<ul> <ul>
<% loop BrowserPollResults %> <% loop $BrowserPollResults %>
<li> <li>
<div class="browser">$Browser: $Percentage%</div> <div class="browser">$Browser: $Percentage%</div>
<div class="bar" style="width:$Percentage%">&nbsp;</div> <div class="bar" style="width:$Percentage%">&nbsp;</div>

View File

@ -33,7 +33,7 @@ To add the search form, we can add `$SearchForm` anywhere in our templates. In t
:::ss :::ss
... ...
<% if SearchForm %> <% if $SearchForm %>
<span class="search-dropdown-icon">L</span> <span class="search-dropdown-icon">L</span>
<div class="search-bar"> <div class="search-bar">
$SearchForm $SearchForm
@ -98,16 +98,16 @@ class.
<div id="Content" class="searchResults"> <div id="Content" class="searchResults">
<h1>$Title</h1> <h1>$Title</h1>
<% if Query %> <% if $Query %>
<p class="searchQuery"><strong>You searched for &quot;{$Query}&quot;</strong></p> <p class="searchQuery"><strong>You searched for &quot;{$Query}&quot;</strong></p>
<% end_if %> <% end_if %>
<% if Results %> <% if $Results %>
<ul id="SearchResults"> <ul id="SearchResults">
<% loop Results %> <% loop $Results %>
<li> <li>
<a class="searchResultHeader" href="$Link"> <a class="searchResultHeader" href="$Link">
<% if MenuTitle %> <% if $MenuTitle %>
$MenuTitle $MenuTitle
<% else %> <% else %>
$Title $Title
@ -124,17 +124,17 @@ class.
<p>Sorry, your search query did not return any results.</p> <p>Sorry, your search query did not return any results.</p>
<% end_if %> <% end_if %>
<% if Results.MoreThanOnePage %> <% if $Results.MoreThanOnePage %>
<div id="PageNumbers"> <div id="PageNumbers">
<% if Results.NotLastPage %> <% if $Results.NotLastPage %>
<a class="next" href="$Results.NextLink" title="View the next page">Next</a> <a class="next" href="$Results.NextLink" title="View the next page">Next</a>
<% end_if %> <% end_if %>
<% if Results.NotFirstPage %> <% if $Results.NotFirstPage %>
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a> <a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
<% end_if %> <% end_if %>
<span> <span>
<% loop Results.Pages %> <% loop $Results.Pages %>
<% if CurrentBool %> <% if $CurrentBool %>
$PageNum $PageNum
<% else %> <% else %>
<a href="$Link" title="View page number $PageNum">$PageNum</a> <a href="$Link" title="View page number $PageNum">$PageNum</a>

View File

@ -293,19 +293,19 @@ a named list of object.
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% loop Children %> <% loop $Children %>
<tr> <tr>
<td> <td>
<a href="$Link">$Title</a> <a href="$Link">$Title</a>
</td> </td>
<td> <td>
<% loop Students %> <% loop $Students %>
$Name ($University)<% if Last !=1 %>,<% end_if %> $Name ($University)<% if $Last !=1 %>,<% end_if %>
<% end_loop %> <% end_loop %>
</td> </td>
<td> <td>
<% loop Mentor %> <% loop $Mentor %>
$Name<% if Last !=1 %>,<% end_if %> $Name<% if $Last !=1 %>,<% end_if %>
<% end_loop %> <% end_loop %>
</td> </td>
</tr> </tr>
@ -343,9 +343,9 @@ we can access the "Students" and "Mentors" relationships directly in the templat
<div class="content"> <div class="content">
$Content $Content
<h2>Students</h2> <h2>Students</h2>
<% if Students %> <% if $Students %>
<ul> <ul>
<% loop Students %> <% loop $Students %>
<li>$Name ($University)</li> <li>$Name ($University)</li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -353,9 +353,9 @@ we can access the "Students" and "Mentors" relationships directly in the templat
<p>No students found</p> <p>No students found</p>
<% end_if %> <% end_if %>
<h2>Mentors</h2> <h2>Mentors</h2>
<% if Mentors %> <% if $Mentors %>
<ul> <ul>
<% loop Mentors %> <% loop $Mentors %>
<li>$Name</li> <li>$Name</li>
<% end_loop %> <% end_loop %>
</ul> </ul>
@ -392,7 +392,7 @@ To use this template, we need to add a new method to our student class:
Replace the student template code in both `Project.ss` Replace the student template code in both `Project.ss`
and `ProjectHolder.ss` templates with the new placeholder, `$Info`. and `ProjectHolder.ss` templates with the new placeholder, `$Info`.
That's the code enclosed in `<% loop Students %>` and `<% end_loop %>`. That's the code enclosed in `<% loop $Students %>` and `<% end_loop %>`.
With this pattern, you can increase code reuse across templates. With this pattern, you can increase code reuse across templates.
## Summary ## Summary