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

Specific blog posts in separate divs


Go to End


2 Posts   1684 Views

Avatar
ramshackle

Community Member, 22 Posts

11 February 2011 at 2:23pm

Hi there,

I have my 3 latest blog posts displaying on the homepage using the "function LatestNews($num=5)" discussed elsewhere, works fine however I'd like to have the latest single post as a 'featured' blog or top story with a photo etc, displaying in it's own div, and the next two most recent blogs underneath in a different div. I can get the single featured blog post ok, problem is displaying the next two on their own - I can display the list of 3 but the top story is repeated. Is there any way of displaying only blog posts Number 2 and 3? Or hiding post 1 from the displayed list?

I dont want to use 2 blog holders either - I want the top news story to move down to the list below automatically when a new story is posted, ie the client only has one blog to update.

Any suggestions much appreciated,
Thanks

Avatar
Phill

Community Member, 81 Posts

12 February 2011 at 12:40pm

Edited: 12/02/2011 12:41pm

Hey

I haven't seen you previous post but you should be able to do something like

<% control LatestNews %>

 <% if First %>
   <div class="first-post">
 <% end_if %>

    $Name
   $Description

 <% if First %>
   </div>
 <% end_if %>

<% end_control %>

Heres the documentation that should help
http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls#dataobjectset-options