17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2110 Views |
-
What's new on my page

23 July 2007 at 2:31am
Hello,
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? And how to export that list as RSS for my subscribers?
Thank you very much
-
Re: What's new on my page

23 July 2007 at 10:00am
Tutorial 2 covers both of those, you should be able to follow that and get a general idea of what to do - http://doc.silverstripe.com/doku.php?id=tutorial:2-extending-a-basic-site.
-
Re: What's new on my page

25 July 2007 at 9:21am
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 pageYou 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/rssNote: You'll probably want to change "LastEdited DESC" to "Date DESC"
Hope this helps,
Elijah Lofgren
| 2110 Views | ||
|
Page:
1
|
Go to Top |



