I'm trying to set up a function to return a short url of the current page.
In mySite/Code/Design.php:
class Design_Controller extends Page_Controller {
function getTrimUrl() {
$pathPartA = $BaseHref;
$pathPartB = $URLSegment;
$pathComplete = $pathPartA.$pathPartB;
$tinyurl = file_get_contents("http://api.tr.im/api/trim_simple?url=$pathComplete");
return $tinyurl;
}
}
then in themes/mhytheme/templates/layout/Design.ss:
<a href="http://twitter.com/home?status=$TwitterText - <% if getTrimURL %>$getTrimURL<% else %>Donkeyballs<% end_if %>"><img src="/themes/mytheme/images/tweet.gif" alt="Tweet about this design!" /></a>
But I get errors from the controller that $BaseHref and $URLSegment are unknown variables. I thought they were supposed to be globally available?