mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Documentation tidying
This commit is contained in:
parent
5304215fc7
commit
5ecb55dfb2
@ -4,7 +4,7 @@
|
||||
Ever wonder when you use `$Title` and `<% Control Children %>` what else you can call in the templates?. This page is
|
||||
here to help with a guide on what template controls you can call.
|
||||
|
||||
**Note for advanced users:** These built-in page controls are defined in the `[api:SiteTree]` classes, which are the
|
||||
**Note for advanced users:** These built-in page controls are defined in the [api:SiteTree] classes, which are the
|
||||
'root' data-object and controller classes for all the sites. So if you're dealing with something that isn't a sub-class
|
||||
of one of these, our handy reference to 'built-in page controls' won't be so relevant.
|
||||
|
||||
@ -18,8 +18,8 @@ within another page control.
|
||||
|
||||
#### <% control Menu(1) %>, <% control Menu(2) %>, ...
|
||||
|
||||
Returns a fixed level menu. Because this only works in the top level, you can't use it for nested menus. Used <%
|
||||
control Children %> instead. You can nest `<% control Children %>`.
|
||||
Returns a fixed level menu. Because this only works in the top level, you can't use it for nested menus. Use
|
||||
`<% control Children %>` instead. You can nest `<% control Children %>`.
|
||||
|
||||
#### <% control ChildrenOf(page-url) %>
|
||||
|
||||
@ -39,7 +39,7 @@ you're on the page __about us > staff > bob marley__:
|
||||
#### <% control Page(my-page) %>$Title<% end_control %>
|
||||
|
||||
"Page" will return a single page from the site tree, looking it up by URL. You can use it in the `<% control %>` format.
|
||||
Can't be called using $Page(my-page).Title.
|
||||
Can't be called using `$Page(my-page).Title`.
|
||||
|
||||
## Page controls that can be used anywhere
|
||||
|
||||
@ -110,7 +110,7 @@ These return different linking modes. $LinkingMode provides the greatest contro
|
||||
* section: A child of this page is currently open, which means that we're currently in this section of the site.
|
||||
* current: This page is currently open.
|
||||
|
||||
A useful way of using this is in your menus. You can use the following code below to generate an class="current" or
|
||||
A useful way of using this is in your menus. You can use the following code below to generate class="current" or
|
||||
class="section" on your links. Take the following code
|
||||
|
||||
:::ss
|
||||
@ -123,8 +123,7 @@ When viewed on the Home page it will render like this
|
||||
<li><a href="home/" class="current">Home</a></li>
|
||||
|
||||
|
||||
$LinkOrCurrent ignores the section status, returning link instead. $LinkOrSection ingores the current status, returning
|
||||
section instead. Both of these options can simplify your CSS when you only have 2 different cases to consider.
|
||||
`$LinkOrCurrent` ignores the section status, returning link instead. `$LinkOrSection` ignores the current status, returning section instead. Both of these options can simplify your CSS when you only have 2 different cases to consider.
|
||||
|
||||
#### <% if LinkOrCurrent = current %>
|
||||
|
||||
@ -181,13 +180,13 @@ file
|
||||
|
||||
#### $ClassName
|
||||
|
||||
Returns the ClassName of the PHP object. Eg if you have a custom HomePage page type with $ClassName in the template, it
|
||||
Returns the ClassName of the PHP object. Eg if you have a custom HomePage page type with `$ClassName` in the template, it
|
||||
will return "HomePage"
|
||||
|
||||
#### $BaseHref
|
||||
|
||||
Returns the base URL for the current site. This is used to populate the `<base>` tag by default, so if you want to
|
||||
override `<% base_tag %>` with a specific piece of HTML, you can do something like `<base href="$BaseHref">``</base>`
|
||||
override `<% base_tag %>` with a specific piece of HTML, you can do something like `<base href="$BaseHref"></base>`
|
||||
|
||||
### Controlling Members and Visitors Data
|
||||
|
||||
@ -211,9 +210,8 @@ If the user is logged in this will print out
|
||||
|
||||
#### <% if PastMember %>
|
||||
|
||||
These controls detect the visitor's previous experience with the site:
|
||||
|
||||
* $PastMember will return true if the visitor has signed up or logged in on the site before
|
||||
Detect the visitor's previous experience with the site. `$PastMember` will return true if the visitor has signed up or
|
||||
logged in on the site before.
|
||||
|
||||
Note that as of version 2.4 `$PastVisitor` is deprecated. If you wish to check if a visitor has been to the site before,
|
||||
set a cookie with `Cookie::set()` and test for it with `Cookie::get()`.
|
||||
@ -222,18 +220,18 @@ set a cookie with `Cookie::set()` and test for it with `Cookie::get()`.
|
||||
|
||||
#### $Now.Nice, $Now.Year
|
||||
|
||||
$Now returns the current date. You can call any of the methods from the `[api:Date]` class on
|
||||
`$Now` returns the current date. You can call any of the methods from the [api:Date] class on
|
||||
it.
|
||||
|
||||
#### $Created.Nice, $Created.Ago
|
||||
|
||||
$Created returns the time the page was created, $Created.Ago returns how long ago the page was created. You can also
|
||||
call any of methods of the `[api:Date]` class on it.
|
||||
`$Created` returns the time the page was created, `$Created.Ago` returns how long ago the page was created. You can also
|
||||
call any of methods of the [api:Date] class on it.
|
||||
|
||||
#### $LastEdited.Nice, $LastEdited.Ago
|
||||
|
||||
$LastEdited returns the time the page was modified, $LastEdited.Ago returns how long ago the page was modified.You can also
|
||||
call any of methods of the `[api:Date]` class on it.
|
||||
`$LastEdited `returns the time the page was modified, `$LastEdited.Ago` returns how long ago the page was modified. You
|
||||
can also call any of methods of the [api:Date] class on it.
|
||||
|
||||
### DataObjectSet Options
|
||||
|
||||
@ -241,21 +239,21 @@ If you are using a DataObjectSet you have a wide range of methods you can call o
|
||||
|
||||
#### <% if Even %>, <% if Odd %>, $EvenOdd
|
||||
|
||||
These controls can be used to do zebra-striping. $EvenOdd will return 'even' or 'odd' as appropriate.
|
||||
These controls can be used to do zebra-striping. `$EvenOdd` will return 'even' or 'odd' as appropriate.
|
||||
|
||||
#### <% if First %>, <% if Last %>, <% if Middle %>, $FirstLast
|
||||
|
||||
These controls can be used to set up special behaviour for the first and last records of a datafeed. `<% if Middle %>` is
|
||||
set when neither first not last are set. $FirstLast will be 'first', 'last', or ''
|
||||
set when neither first not last are set. `$FirstLast` will be 'first', 'last', or ''.
|
||||
|
||||
#### $Pos, $TotalItems
|
||||
|
||||
$TotalItems will return the number of items on this page of the datafeed, and Pos will return a counter starting at 1.
|
||||
`$TotalItems` will return the number of items on this page of the datafeed, and `$Pos` will return a counter starting at 1.
|
||||
|
||||
#### $Top
|
||||
|
||||
When you're inside a control loop in your template, and want to reference methods on the current controller you're on,
|
||||
breaking out of the loop to get it, you can use $Top to do so. For example:
|
||||
breaking out of the loop to get it, you can use `$Top` to do so. For example:
|
||||
|
||||
:::ss
|
||||
$URLSegment
|
||||
@ -267,7 +265,7 @@ breaking out of the loop to get it, you can use $Top to do so. For example:
|
||||
|
||||
## Properties of a datafeed itself, rather than one of its items
|
||||
|
||||
If we have a control such as `<% control SearchResults %>`, there are some properties, such as $SearchResults.NextLink,
|
||||
If we have a control such as `<% control SearchResults %>`, there are some properties, such as `$SearchResults.NextLink`,
|
||||
that aren't accessible within `<% control SearchResults %>`. These can be used on any datafeed.
|
||||
|
||||
### Search Results
|
||||
@ -279,8 +277,8 @@ Returns true when we have a multi-page datafeed, restricted with a limit.
|
||||
#### $SearchResults.NextLink, $SearchResults.PrevLink
|
||||
|
||||
This returns links to the next and previous page in a multi-page datafeed. They will return blank if there's no
|
||||
appropriate page to go to, so $PrevLink will return blank when you're on the first page. You can therefore use <% if
|
||||
PrevLink %> to keep your template tidy.
|
||||
appropriate page to go to, so `$PrevLink` will return blank when you're on the first page. You can therefore use
|
||||
`<% if PrevLink %>` to keep your template tidy.
|
||||
|
||||
#### $SearchResults.CurrentPage, $SearchResults.TotalPages
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user