Hi all,
I am trying to do as you suggest, but even after a /dev/build?flush=1, my changes in the template don’t work.
Here is my complete /mysite/code/Page.php:
<?php
class Page extends SiteTree {
private static $db = array(
);
private static $has_one = array(
);
}
class Page_Controller extends ContentController {
/**
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
* permissions or conditions required to allow the user to access it.
*
* <code>
* array (
* 'action', // anyone can access this action
* 'action' => true, // same as above
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
* );
* </code>
*
* @var array
*/
private static $allowed_actions = array (
);
public function init() {
parent::init();
// You can include any CSS or JS required by your project here.
// See: http://doc.silverstripe.org/framework/en/reference/requirements
}
function LatestPost($num=5) {
$blogpost = DataObject::get_one("BlogHolder");
return ($blogpost) ? DataObject::get("BlogEntry", "", "Date DESC", "", $num) : false;
}
public function UsersIpAddress() {
return $this->request->getIP();
}
}
Then in Page.ss I have:
<% loop LatestPost %>
<p>You are coming from $UsersIpAddress.</p>
<ul id="NewsList">
<li class="newsDateTitle"><span class="date">Date $Date</span><a href="$Link" title="Lesen Sie mehr über "{$Title}"">Title $Title</a></li>
</ul>
<% end_loop %>
</ul>
</div>
But it doesn't output anything from the data model, just this HTML:
<div id="aktuelles">
<p>You are coming from .</p>
<ul id="NewsList">
<li class="newsDateTitle"><span class="date">Date </span><a href="" title="Lesen Sie mehr über """>Title </a></li>
</ul>
</ul>
</div>
The IP address function was just to see if it was working at all, which it isn’t. I thought maybe I was editing the wrong file, but my changes do show up, just the controller isn’t outputting the loop. I must be missing something obvious.
Um…help?
Cheers,
John