Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » The 5 last edited pages in a list

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 282 Views
  • LEDfan
    Avatar
    Community Member
    2 Posts

    The 5 last edited pages in a list Link to this post

    Hi

    First I want to say sorry for my bad English...

    I'm using silverstripe for a few days, and I like it.
    I'm using the pixelgreen theme.
    I'd like to show the last edited pages in the sidebar.
    I have found in my database that I need to use the SiteTree table.
    My php knowledge is not so good. I am able to make contact with my database, and select the right table.

    I'm searching for a script that gets the last 5 edits from my table, and that organizes these 5 edits.

    Thanks a lot

  • LEDfan
    Avatar
    Community Member
    2 Posts

    Re: The 5 last edited pages in a list Link to this post

    Hi

    I can get te last edited pages out my database.
    But new i need to put it in the sidebar, how do i do that?

    <?php
    $con = mysql_connect("localhost","NAME","PASS");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("robots4funbe_cms", $con);

    $result = mysql_query("SELECT * FROM SiteTree WHERE ID >'10' ORDER BY Created ASC LIMIT 0, 5");

    echo "<table border='1'>
    <tr>
    <th>ID</th>
    <th>Createed</th>
    <th>Title</th>
    </tr>";

    while($row = mysql_fetch_array($result))
    {
    echo "<tr><td>" . $row['ID'];"</td>";
    echo "<td>" . $row['Created'];"</td>";
    echo "<td>" . $row['Title'];"</td></tr>";
    }

    mysql_close($con);
    ?>

    Thanks a lot.

  • swaiba
    Avatar
    Forum Moderator
    1785 Posts

    Re: The 5 last edited pages in a list Link to this post

    Hi LEDfan,

    This post may help...
    http://www.silverstripe.org/data-model-questions/show/17245#post304677

    In silverstripe a DataObjectSet is parsable easily on the template and instead of using the mysql_connect functions this provides a slightly higher level to getting the data and formatting it. I am sure there is a way to do this using entriely DataObject::Get - but I'll just offer this to help you now.

    282 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.