Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

Get latest blog entries from BlogTree sections


Go to End


1752 Views

Avatar
sajok

Community Member, 82 Posts

13 October 2010 at 1:31am

Hello,

I have subclassed my website into small sections (BlogHolders) and big sections which include other blogHolders (BlogTree). I have an horizontal accordion showcase on homepage to show the latest four news entries, and each entry is from a specific blog holder or blog tree.

This is the structure of my website:

1. Home

2. Politics => BogHolder

3. Economie => BlogHolder

4. Culture => BlogTree

a. Local =>BlogHolder
b. Regional =>BlogHolder
c. Nationa =>BlogHolder

5. Sports => BlogTree

a. Local =>BlogHolder
b. Regional =>BlogHolder
c. Nationa =>BlogHolder
...

I tried something like the following to show the latest entry from a BlogTree but it doesn't work:

    function LatestNews($title) {
    $news = DataObject::get_one('BlogTree', "URLSegment = '$title'");
    return ($news) ? DataObject::get("BlogEntry", "ParentID = $news->ID", "Date DESC", "", 1) : false;
    }

Any help on how can I get news from this structure?

thanks