Examples
Below are a series of working examples complete with the output that each snippet returns.
Creating a basic link
<?php echo sitecmd::link('http://www.example.com/', 'Link to Example') ?>
<a href="http://www.example.com/">Link to Example</a>
Creating a link without a name
<?php echo sitecmd::link('http://www.example.com/') ?>
<a href="http://www.example.com/">http://www.example.com/</a>
Creating a link with a 'target' attribute (i.e. open the link in a new window)
<?php echo sitecmd::link('http://www.example.com/', 'Link to Example', array('target' => '_blank')) ?>
<a href="http://www.example.com/" target="_blank">http://www.example.com/</a>
Creating a link with 'target' and 'class' attributes
<?php echo sitecmd::link('http://www.example.com/', 'Link to Example', array('target' => '_blank', 'class' => 'my-link')) ?>
<a href="http://www.example.com/" target="_blank" class="my-link">http://www.example.com/</a>
Event Callback Function
The following example will show you how to find and replace text in your page content whenever a page is loaded.
// site/_media/events.php
function replace_content($content)
{
$content = str_replace('find', 'replace', $content);
}
sitecmd::addEvent('page-content', 'replace_content');
Getting the current page name
// http://www.example.com/foo/bar <?php echo sitecmd::getPage() ?>
bar
Comparing page names
// http://www.example.com/foo/bar
<?php echo sitecmd::getPage('baz') ?>
false