Hi tomasulej,
> All page types on my site have $Date field and I would like to have page "What's new on my site" where all pages will be displayed according to $Date. Do you have any idea how to do that?
Here is what I just implemented on http://new.elijahlofgren.com/
1. Put the following code in a HomePage.php file and upload it to mysite/code:
/**
* Defines the HomePage page type
*/
class HomePage extends Page {
static $icon = "mysite/images/treeicons/home";
static $db = array(
);
static $has_one = array(
);
}
class HomePage_Controller extends Page_Controller {
function RecentlyUpdated() {
$pages = DataObject::get("Page", "", "LastEdited DESC", "", 10);
$doSet = new DataObjectSet();
foreach($pages as $key => $data) {
$title = $data->Title;
$record = array(
'Link' => $data->Link(),
'Title' => $title,
'Date' => $data->LastEdited
);
$doSet->push(new ArrayData($record));
}
return $doSet;
}
}
Note: You'll probably want to change "'Date' => $data->LastEdited" to "'Date' => $data->Date" and "LastEdited DESC" to "Date DESC"
2. Put the following code in a HomePage.ss file and upload it to mysite/templates/Layout
[html]
<h2>$Title</h2>
$Content
<h3>Most Recent Updates</h3>
<ul>
<% control RecentlyUpdated %>
<li>
$Date - <a href="$Link">$Title</a>
</li>
<% end_control %>
</ul>
$Form
$PageComments
[/html]
3. Go to /db/build/ (you may need to put your site in devmode in order to allow db/build to be run (sometimes logging in with the your password doesn't work))
4. Go to /admin?flush=1 and change your home page to have Page Type "HomePage" as described here Changing the page type of the Home page
You can see this code running here: http://new.elijahlofgren.com/
> And how to export that list as RSS for my subscribers?
I've posted an example of how to show the latest updates
RSSFeed: Example of showing the 10 most recently updated pages
Here is that code running: http://new.elijahlofgren.com/home/rss
Note: You'll probably want to change "LastEdited DESC" to "Date DESC"
Hope this helps,
Elijah Lofgren