Template

How to use operations

Operations are performed using sections, accepting its rendered contents as an argument.

Definitions
Name Argument Description
capitaliseNew Text Transform the text provided into title case
cookie Text Get the value for the cookie with the name provided
dateTime Text Format the current date & time using the pattern provided
(see PHPs date for more details)
decode Text Decode the previously encoded text provided
encode Text Encode the text provided so that it can be safely used in a query string
fparam Text Get the value of the parameter provided from within the hash fragment
fsegment Number Get the segment at the index provided from within the hash fragment
lastModified ¹ Text Format the last modified date & time using the pattern provided
(see PHPs date for more details)
lengthNew Text Get the character length of the text provided
lowerCaseNew Text Transform the text provided into lower case
param Text Get the value of the parameter provided
segment Number Get the segment at the index provided
shorten Text Shorten the URL provided using the active URL shortener
tidyNew Text Reduce all of the joined spaces and tabs into single spaces within the text provided before removing all leading and trailing whitespace
trimNew Text Remove all leading and trailing whitespace from the text provided
trimLeftNew Text Remove all leading whitespace from the text provided
trimRightNew Text Remove all trailing whitespace from the text provided
upperCaseNew Text Transform the text provided into upper case

This page's information will be used in the following examples.

To output the current date & time in ISO 8601 format you would use;

Today is {#dateTime}Y-m-d\TH:i:sP{/dateTime}.

Also, the c parameter would also have the same outcome in this case. If you wanted to safely pass the whole URL as a parameter in a query string;

http://example.com/something.do?url={#encode}{url}{/encode}

This escapes all of the necessary characters within URL and outputs the following;

http://example.com/something.do?url=http%3A%2F%2Fneocotic.com%2Ftemplate%2Fguide%2Foperations

To access the last segment of the URL's path;

I am currently viewing "{#segment}-1{/segment}".

Would render the following output;

I am currently viewing "operations".

Let's pretend again that the query string for this page is foo=bar&fu=baz. Accessing the value of the foo parameter is as simple as the following;

The value of foo is "{#param}foo{/param}".

This would cause the following output to be rendered;

The value of foo is "bar".

Notes

The following notes only apply to segment and fsegment operations;

  • The count is not zero-indexed like an array (e.g. {#segment}1{/segment} returns the first segment)
  • The argument can be negative values, in which case it will count back from the end of the path rather than forwards from the start