bludit/content/pages/themes/variables/index.txt

83 lines
2.1 KiB
Plaintext
Raw Normal View History

2015-03-10 16:39:04 +01:00
Title: Theme variables
2015-03-08 18:02:59 +01:00
Content:
2015-03-10 16:39:04 +01:00
## $pages arrays
This array cotains all pages published. Each item from the array is a `Page Object`
---
## Array $posts
---
## Site object
The object Site have all the information from the database /content/databases/site.php.
By default there is an object $Site, whith the next methods.
2015-03-08 18:02:59 +01:00
Print the site title
<pre><code data-language="php">echo $Site->title();</code></pre>
Print the site slogan
<pre><code data-language="php">echo $Site->slogan();</code></pre>
2015-03-10 16:39:04 +01:00
---
## Page object
By default if the user filter by a particular page there will be an object $Page. To check if the user is filtering by a page you can uses the object $Url and the method `whereAmI()`.
<pre><code data-language="php">if( $Url->whereAmI()==='page' )
{
echo 'The page filtered is '.$Page->title();
}
{
echo 'The user is not watching a particular page';
}
</code></pre>
And here there are the methods for the object $Page.
2015-03-08 18:02:59 +01:00
Print the page title
<pre><code data-language="php">echo $Page->title();</code></pre>
Print the page content
<pre><code data-language="php">echo $Page->content();</code></pre>
Print the page username
<pre><code data-language="php">echo $Page->username();</code></pre>
Get the date in unix timestamp
<pre><code data-language="php">$time = $Page->unixstamp();
// Format time
echo date('Y-m-d', $time);
</code></pre>
Print the page date, according to locale settings and format settings.
<pre><code data-language="php">echo $Page->date();</code></pre>
Print the page date with a different format.
<pre><code data-language="php">$format = 'Y-m-d';
echo $Page->date($format);
</code></pre>
Time ago
<pre><code data-language="php">echo $Page->timeago();</code></pre>
Get the slug url.
<pre><code data-language="php">$slug = $Page->slug();</code></pre>
Get the page permalink.
<pre><code data-language="php">$permalink = $Page->permalink();</code></pre>
Get the page status, this method returns TRUE if the page is published, FALSE otherwise.
<pre><code data-language="php">if( $Page->published() )
{
echo 'Page published';
}
else
{
echo 'Page draft';
}</code></pre>