mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Consistently used dollar notation in template docs (see #1794)
This commit is contained in:
parent
b211f22bf9
commit
5f91c3724d
@ -129,7 +129,7 @@ and replace it with the following:
|
||||
|
||||
:::ss
|
||||
<ul>
|
||||
<% loop BookmarkedPages %>
|
||||
<% loop $BookmarkedPages %>
|
||||
<li><a href="admin/pages/edit/show/$ID">Edit "$Title"</a></li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
|
@ -74,10 +74,10 @@ In this case, the `getTitleFirstLetter()` method defined earlier is used to brea
|
||||
:::ss
|
||||
<%-- Modules list grouped by TitleFirstLetter --%>
|
||||
<h2>Modules</h2>
|
||||
<% loop GroupedModules.GroupedBy(TitleFirstLetter) %>
|
||||
<% loop $GroupedModules.GroupedBy(TitleFirstLetter) %>
|
||||
<h3>$TitleFirstLetter</h3>
|
||||
<ul>
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<li>$Title</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
@ -133,10 +133,10 @@ 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>
|
||||
<% loop GroupedModulesByDate.GroupedBy(MonthCreated) %>
|
||||
<% loop $GroupedModulesByDate.GroupedBy(MonthCreated) %>
|
||||
<h3>$MonthCreated</h3>
|
||||
<ul>
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<li>$Title ($Created.Nice)</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
|
@ -9,7 +9,7 @@ located in `themes/<mytheme>/templates/Page.ss`.
|
||||
|
||||
:::ss
|
||||
<ul>
|
||||
<% loop Menu(1) %>
|
||||
<% loop $Menu(1) %>
|
||||
<li>
|
||||
<a href="$Link" title="Go to the $Title page" class="$LinkingMode">
|
||||
<span>$MenuTitle</span>
|
||||
|
@ -36,7 +36,7 @@ The first step is to simply list the objects in the template:
|
||||
|
||||
:::ss
|
||||
<ul>
|
||||
<% loop PaginatedPages %>
|
||||
<% loop $PaginatedPages %>
|
||||
<li><a href="$Link">$Title</a></li>
|
||||
<% end_loop %>
|
||||
</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:
|
||||
|
||||
:::ss
|
||||
<% if PaginatedPages.MoreThanOnePage %>
|
||||
<% if PaginatedPages.NotFirstPage %>
|
||||
<% if $PaginatedPages.MoreThanOnePage %>
|
||||
<% if $PaginatedPages.NotFirstPage %>
|
||||
<a class="prev" href="$PaginatedPages.PrevLink">Prev</a>
|
||||
<% end_if %>
|
||||
<% loop PaginatedPages.Pages %>
|
||||
<% if CurrentBool %>
|
||||
<% loop $PaginatedPages.Pages %>
|
||||
<% if $CurrentBool %>
|
||||
$PageNum
|
||||
<% else %>
|
||||
<% if Link %>
|
||||
<% if $Link %>
|
||||
<a href="$Link">$PageNum</a>
|
||||
<% else %>
|
||||
...
|
||||
<% end_if %>
|
||||
<% end_if %>
|
||||
<% end_loop %>
|
||||
<% if PaginatedPages.NotLastPage %>
|
||||
<% if $PaginatedPages.NotLastPage %>
|
||||
<a class="next" href="$PaginatedPages.NextLink">Next</a>
|
||||
<% end_if %>
|
||||
<% end_if %>
|
||||
|
@ -427,7 +427,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 `<% 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
|
||||
|
||||
### SQL Format
|
||||
|
@ -215,7 +215,7 @@ Failing example:
|
||||
:::ss
|
||||
<% cached LastEdited %>
|
||||
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<% cached LastEdited %>
|
||||
$Name
|
||||
<% end_cached %>
|
||||
@ -231,7 +231,7 @@ Can be re-written as:
|
||||
<% cached LastEdited %>
|
||||
|
||||
<% cached Children.max(LastEdited) %>
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
$Name
|
||||
<% end_loop %>
|
||||
<% end_cached %>
|
||||
|
@ -139,9 +139,9 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
|
||||
|
||||
|
||||
:::ss
|
||||
<% if Results %>
|
||||
<% if $Results %>
|
||||
<ul>
|
||||
<% loop Results %>
|
||||
<% loop $Results %>
|
||||
<li>$Title, $Autor</li>
|
||||
<% end_loop %>
|
||||
</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>
|
||||
<% end_if %>
|
||||
|
||||
<% if Results.MoreThanOnePage %>
|
||||
<% if $Results.MoreThanOnePage %>
|
||||
<div id="PageNumbers">
|
||||
<p>
|
||||
<% if Results.NotFirstPage %>
|
||||
<% if $Results.NotFirstPage %>
|
||||
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
|
||||
<% end_if %>
|
||||
|
||||
<span>
|
||||
<% loop Results.PaginationSummary(4) %>
|
||||
<% if CurrentBool %>
|
||||
<% loop $Results.PaginationSummary(4) %>
|
||||
<% if $CurrentBool %>
|
||||
$PageNum
|
||||
<% else %>
|
||||
<% if Link %>
|
||||
<% if $Link %>
|
||||
<a href="$Link" title="View page number $PageNum">$PageNum</a>
|
||||
<% else %>
|
||||
…
|
||||
@ -170,7 +170,7 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
|
||||
<% end_loop %>
|
||||
</span>
|
||||
|
||||
<% if Results.NotLastPage %>
|
||||
<% if $Results.NotLastPage %>
|
||||
<a class="next" href="$Results.NextLink" title="View the next page">Next</a>
|
||||
<% end_if %>
|
||||
</p>
|
||||
|
@ -15,7 +15,7 @@ You can access `[api:SiteConfig]` options from any SS template by using the func
|
||||
|
||||
// or
|
||||
|
||||
<% loop SiteConfig %>
|
||||
<% loop $SiteConfig %>
|
||||
$Title $AnotherField
|
||||
<% end_loop %>
|
||||
|
||||
|
@ -4,9 +4,9 @@ These are the main changes to the SiverStripe 3 template language.
|
||||
|
||||
## 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
|
||||
|
||||
|
@ -26,9 +26,9 @@ Here is a very simple template:
|
||||
<p>Welcome $FirstName $Surname.</p>
|
||||
<% end_with %>
|
||||
|
||||
<% if Dishes %>
|
||||
<% if $Dishes %>
|
||||
<ul>
|
||||
<% loop Dishes %>
|
||||
<% loop $Dishes %>
|
||||
<li>$Title ($Price.Nice)</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
@ -106,7 +106,7 @@ The "include" tag can be particularly helpful for nested functionality. In this
|
||||
a variable is true
|
||||
|
||||
:::ss
|
||||
<% if CurrentMember %>
|
||||
<% if $CurrentMember %>
|
||||
<% include MembersOnlyInclude %>
|
||||
<% 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
|
||||
|
||||
:::ss
|
||||
<% with CurrentMember %>
|
||||
<% with $CurrentMember %>
|
||||
<% include MemberDetails PageTitle=$Top.Title, PageID=$Top.ID %>
|
||||
<% 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.
|
||||
|
||||
:::ss
|
||||
<% if not $DinnerInOven %>
|
||||
<% if $not $DinnerInOven %>
|
||||
I'm going out for dinner tonight.
|
||||
<% end_if %>
|
||||
|
||||
@ -309,7 +309,7 @@ this case we want to add a <br> after every 3th item.
|
||||
|
||||
:::ss
|
||||
<% loop $Children %>
|
||||
<% if MultipleOf(3) %>
|
||||
<% if $MultipleOf(3) %>
|
||||
<br>
|
||||
<% end_if %>
|
||||
<% 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.
|
||||
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.
|
||||
|
||||
:::ss
|
||||
<% if CurrentMember %>
|
||||
<% if $CurrentMember %>
|
||||
Welcome Back, $CurrentMember.FirstName
|
||||
<% 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
|
||||
|
||||
:::ss
|
||||
<% with MyCustomValues %>
|
||||
<% with $MyCustomValues %>
|
||||
$Hi , $Name
|
||||
<% end_with %>
|
||||
// output "Kia Ora , John Smith"
|
||||
|
@ -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.
|
||||
|
||||
:::ss
|
||||
<% if MyObjectInstance.MyDate.InPast %>Outdated!<% end_if %>
|
||||
<% if $MyObjectInstance.MyDate.InPast %>Outdated!<% end_if %>
|
||||
|
||||
## Casting HTML Text
|
||||
|
||||
|
@ -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->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() {
|
||||
return $this->Team()->BaseFee * $this->MembershipYears;
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ basic customisation:
|
||||
|
||||
:::ss
|
||||
<form $FormAttributes>
|
||||
<% if Message %>
|
||||
<% if $Message %>
|
||||
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
|
||||
<% else %>
|
||||
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
|
||||
@ -284,9 +284,9 @@ basic customisation:
|
||||
$Fields.dataFieldByName(SecurityID)
|
||||
</fieldset>
|
||||
|
||||
<% if Actions %>
|
||||
<% if $Actions %>
|
||||
<div class="Actions">
|
||||
<% loop Actions %>$Field<% end_loop %>
|
||||
<% loop $Actions %>$Field<% end_loop %>
|
||||
</div>
|
||||
<% end_if %>
|
||||
</form>
|
||||
@ -297,7 +297,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 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.
|
||||
|
||||
### Custom form field templates
|
||||
|
@ -378,7 +378,7 @@ Template:
|
||||
|
||||
:::ss
|
||||
<ul>
|
||||
<% loop Results %>
|
||||
<% loop $Results %>
|
||||
<li id="Result-$ID">$Title</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
|
@ -95,15 +95,15 @@ Note that pages with the `ShowInMenus` property set to FALSE will be filtered ou
|
||||
### Children Loops
|
||||
|
||||
:::ss
|
||||
<% loop Children %>...<% end_loop %>
|
||||
<% loop $Children %>...<% end_loop %>
|
||||
|
||||
Will loop over all children of the current page context.
|
||||
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.
|
||||
|
||||
:::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,
|
||||
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.
|
||||
|
||||
:::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.
|
||||
|
||||
@ -137,7 +137,7 @@ To simply retrieve the parent page of the current context (if existing), use the
|
||||
### Access to a specific Page
|
||||
|
||||
:::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.
|
||||
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:
|
||||
|
||||
:::ss
|
||||
<% if LinkOrCurrent = current %>
|
||||
<% if $LinkOrCurrent = current %>
|
||||
$Title
|
||||
<% else %>
|
||||
<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:
|
||||
|
||||
:::ss
|
||||
<% if Pages %>
|
||||
<% loop Pages %>
|
||||
<% if Last %>$Title.XML<% else %><a href="$Link">$MenuTitle.XML</a> »<% end_if %>
|
||||
<% if $Pages %>
|
||||
<% loop $Pages %>
|
||||
<% if $Last %>$Title.XML<% else %><a href="$Link">$MenuTitle.XML</a> »<% end_if %>
|
||||
<% end_loop %>
|
||||
<% end_if %>
|
||||
|
||||
|
@ -121,7 +121,7 @@ of the CMS you have to take care of instanciation yourself:
|
||||
:::ss
|
||||
// File: mysite/templates/MyController.ss
|
||||
$Form
|
||||
<% with EditorToolbar %>
|
||||
<% with $EditorToolbar %>
|
||||
$MediaForm
|
||||
$LinkForm
|
||||
<% end_with %>
|
||||
|
@ -72,9 +72,9 @@ our theme in action. The code for mine is below.
|
||||
</div>
|
||||
|
||||
<div id="Navigation">
|
||||
<% if Menu(1) %>
|
||||
<% if $Menu(1) %>
|
||||
<ul>
|
||||
<% loop Menu(1) %>
|
||||
<% loop $Menu(1) %>
|
||||
<li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
@ -180,9 +180,9 @@ Next is a division for the main navigation. This may contain something like:
|
||||
|
||||
:::ss
|
||||
<div id="Navigation">
|
||||
<% if Menu(1) %>
|
||||
<% if $Menu(1) %>
|
||||
<ul>
|
||||
<% loop Menu(1) %>
|
||||
<% loop $Menu(1) %>
|
||||
<li><a href="$Link" title="Go to the $Title page" class="$LinkingMode">$MenuTitle</a></li>
|
||||
<% end_loop %>
|
||||
</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!
|
||||
|
||||
:::ss
|
||||
<% if MyFunction %>
|
||||
<% loop MyFunction %>
|
||||
<% if $MyFunction %>
|
||||
<% loop $MyFunction %>
|
||||
$Title
|
||||
<% end_loop %>
|
||||
<% end_if %>
|
||||
|
@ -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.
|
||||
|
||||
:::ss
|
||||
<% loop Menu(1) %>
|
||||
<% loop $Menu(1) %>
|
||||
|
||||
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).
|
||||
@ -168,7 +168,7 @@ returns a set of first level menu items. We can then use the template variable
|
||||
|
||||
:::ss
|
||||
<ul>
|
||||
<% loop Menu(1) %>
|
||||
<% loop $Menu(1) %>
|
||||
<li class="$LinkingMode">
|
||||
<a href="$Link" title="$Title.XML">$MenuTitle.XML</a>
|
||||
</li>
|
||||
@ -225,7 +225,7 @@ Adding a second level menu is very similar to adding the first level menu. Open
|
||||
|
||||
:::ss
|
||||
<ul>
|
||||
<% loop Menu(2) %>
|
||||
<% loop $Menu(2) %>
|
||||
<li class="$LinkingMode">
|
||||
<a href="$Link" title="Go to the $Title.XML page">
|
||||
<span class="arrow">→</span>
|
||||
@ -245,10 +245,10 @@ Look again in the *Sidebar.ss* file and you will see that the menu is surrounded
|
||||
like this:
|
||||
|
||||
:::ss
|
||||
<% if Menu(2) %>
|
||||
<% if $Menu(2) %>
|
||||
...
|
||||
<ul>
|
||||
<% loop Menu(2) %>
|
||||
<% loop $Menu(2) %>
|
||||
<li class="$LinkingMode">
|
||||
<a href="$Link" title="Go to the $Title.XML page">
|
||||
<span class="arrow">→</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:
|
||||
|
||||
:::ss
|
||||
<% if Level(2) %>
|
||||
<% if $Level(2) %>
|
||||
<div id="Breadcrumbs">
|
||||
$Breadcrumbs
|
||||
</div>
|
||||
@ -295,12 +295,12 @@ The following example runs an if statement, and a loop on *Children*, checking t
|
||||
|
||||
:::ss
|
||||
<ul>
|
||||
<% loop Menu(1) %>
|
||||
<% loop $Menu(1) %>
|
||||
<li class="$LinkingMode">
|
||||
<a href="$Link" title="$Title.XML">$MenuTitle.XML</a>
|
||||
<% if Children %>
|
||||
<% if $Children %>
|
||||
<ul>
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<li class="$LinkingMode">
|
||||
<a href="$Link" title="Go to the $Title.XML page">
|
||||
<span class="arrow">→</span>
|
||||
|
@ -285,7 +285,7 @@ We'll now create a template for the article holder. We want our news section to
|
||||
$Content
|
||||
<div class="content">$Content</div>
|
||||
</article>
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<article>
|
||||
<h2><a href="$Link" title="Read more on "{$Title}"">$Title</a></h2>
|
||||
<p>$Content.FirstParagraph</p>
|
||||
@ -313,7 +313,7 @@ Cut the code between "loop Children" in *ArticleHolder.ss** and replace it with
|
||||
|
||||
:::ss
|
||||
...
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<% include ArticleTeaser %>
|
||||
<% 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>
|
||||
</article>
|
||||
<% loop LatestNews %>
|
||||
<% loop $LatestNews %>
|
||||
<% include ArticleTeaser %>
|
||||
<% end_loop %>
|
||||
|
||||
@ -489,7 +489,7 @@ The staff section templates aren't too difficult to create, thanks to the utilit
|
||||
$Content
|
||||
<div class="content">$Content</div>
|
||||
</article>
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<article>
|
||||
<h2><a href="$Link" title="Read more on "{$Title}"">$Title</a></h2>
|
||||
$Photo.SetWidth(150)
|
||||
|
@ -325,11 +325,11 @@ The final step is to create the template to display our data. Change the 'Browse
|
||||
:::ss
|
||||
<div id="BrowserPoll">
|
||||
<h2>Browser Poll</h2>
|
||||
<% if BrowserPollForm %>
|
||||
<% if $BrowserPollForm %>
|
||||
$BrowserPollForm
|
||||
<% else %>
|
||||
<ul>
|
||||
<% loop BrowserPollResults %>
|
||||
<% loop $BrowserPollResults %>
|
||||
<li>
|
||||
<div class="browser">$Browser: $Percentage%</div>
|
||||
<div class="bar" style="width:$Percentage%"> </div>
|
||||
|
@ -33,7 +33,7 @@ To add the search form, we can add `$SearchForm` anywhere in our templates. In t
|
||||
|
||||
:::ss
|
||||
...
|
||||
<% if SearchForm %>
|
||||
<% if $SearchForm %>
|
||||
<span class="search-dropdown-icon">L</span>
|
||||
<div class="search-bar">
|
||||
$SearchForm
|
||||
@ -98,16 +98,16 @@ class.
|
||||
<div id="Content" class="searchResults">
|
||||
<h1>$Title</h1>
|
||||
|
||||
<% if Query %>
|
||||
<% if $Query %>
|
||||
<p class="searchQuery"><strong>You searched for "{$Query}"</strong></p>
|
||||
<% end_if %>
|
||||
|
||||
<% if Results %>
|
||||
<% if $Results %>
|
||||
<ul id="SearchResults">
|
||||
<% loop Results %>
|
||||
<% loop $Results %>
|
||||
<li>
|
||||
<a class="searchResultHeader" href="$Link">
|
||||
<% if MenuTitle %>
|
||||
<% if $MenuTitle %>
|
||||
$MenuTitle
|
||||
<% else %>
|
||||
$Title
|
||||
@ -124,17 +124,17 @@ class.
|
||||
<p>Sorry, your search query did not return any results.</p>
|
||||
<% end_if %>
|
||||
|
||||
<% if Results.MoreThanOnePage %>
|
||||
<% if $Results.MoreThanOnePage %>
|
||||
<div id="PageNumbers">
|
||||
<% if Results.NotLastPage %>
|
||||
<% if $Results.NotLastPage %>
|
||||
<a class="next" href="$Results.NextLink" title="View the next page">Next</a>
|
||||
<% end_if %>
|
||||
<% if Results.NotFirstPage %>
|
||||
<% if $Results.NotFirstPage %>
|
||||
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
|
||||
<% end_if %>
|
||||
<span>
|
||||
<% loop Results.Pages %>
|
||||
<% if CurrentBool %>
|
||||
<% loop $Results.Pages %>
|
||||
<% if $CurrentBool %>
|
||||
$PageNum
|
||||
<% else %>
|
||||
<a href="$Link" title="View page number $PageNum">$PageNum</a>
|
||||
|
@ -293,19 +293,19 @@ a named list of object.
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% loop Children %>
|
||||
<% loop $Children %>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="$Link">$Title</a>
|
||||
</td>
|
||||
<td>
|
||||
<% loop Students %>
|
||||
$Name ($University)<% if Last !=1 %>,<% end_if %>
|
||||
<% loop $Students %>
|
||||
$Name ($University)<% if $Last !=1 %>,<% end_if %>
|
||||
<% end_loop %>
|
||||
</td>
|
||||
<td>
|
||||
<% loop Mentor %>
|
||||
$Name<% if Last !=1 %>,<% end_if %>
|
||||
<% loop $Mentor %>
|
||||
$Name<% if $Last !=1 %>,<% end_if %>
|
||||
<% end_loop %>
|
||||
</td>
|
||||
</tr>
|
||||
@ -343,9 +343,9 @@ we can access the "Students" and "Mentors" relationships directly in the templat
|
||||
<div class="content">
|
||||
$Content
|
||||
<h2>Students</h2>
|
||||
<% if Students %>
|
||||
<% if $Students %>
|
||||
<ul>
|
||||
<% loop Students %>
|
||||
<% loop $Students %>
|
||||
<li>$Name ($University)</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
@ -353,9 +353,9 @@ we can access the "Students" and "Mentors" relationships directly in the templat
|
||||
<p>No students found</p>
|
||||
<% end_if %>
|
||||
<h2>Mentors</h2>
|
||||
<% if Mentors %>
|
||||
<% if $Mentors %>
|
||||
<ul>
|
||||
<% loop Mentors %>
|
||||
<% loop $Mentors %>
|
||||
<li>$Name</li>
|
||||
<% end_loop %>
|
||||
</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`
|
||||
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.
|
||||
|
||||
## Summary
|
||||
|
Loading…
Reference in New Issue
Block a user