1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » Blog Posts on HomePage in Columns... Stuck!
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1416 Views |
-
Blog Posts on HomePage in Columns... Stuck!

8 August 2009 at 6:54am
Hi guys,
I've spent the day playing with SilverStripe and have fallen in love with the CMS and will be using it for pretty much all the sites I work on in future.
However I've hit a bit of a stumbling block with my first Silverstripe site, I am trying to get two blog posts shown on the homepage as in this image: http://img527.imageshack.us/img527/4167/43445519.jpg
I've managed to get blog posts to the homepage using code courtesy of Fuzz10:
HomePage.php:
function MyBlogEntries($limit = 1) {
$BlogEntries = DataObject::get_one("BlogHolder");
return ($BlogEntries) ? DataObject::get("BlogEntry", "ParentID = $BlogEntries->ID", "Date DESC", "", $limit) : false;
}and
HomePage.ss:
<% control MyBlogEntries %> { ... } <% end_control%>
In WordPress I would simply use two separate "wp_loop" statements, one for the latest and one for the second newest posts. Is there a way of doing the same here? The CSS side of things is already done so I am just stumped with the SilverStripe template code.
Thanks for your help guys, very much appreciated,
Stewart
-
Re: Blog Posts on HomePage in Columns... Stuck!

8 August 2009 at 11:17am
Your almost there, just change the line in HomePage.php to:
function MyBlogEntries($limit = 2) {
Should do the trick
-
Re: Blog Posts on HomePage in Columns... Stuck!

25 August 2009 at 6:10am
Thanks Howard, I meant to say thanks last week but it's been a mad house! lol. Many thanks.
-
Re: Blog Posts on HomePage in Columns... Stuck!

4 October 2009 at 5:25pm
Hi stew,
I'm trying to do a similar task but can't really work it out since I'm relatively new to coding in SilverStripe. Could you please elaborate more on this part?
<% control MyBlogEntries %> { ... } <% end_control%>
What should I place in { ... }
to display things such as title, author and date?
Many thanks!
-
Re: Blog Posts on HomePage in Columns... Stuck!

4 October 2009 at 11:34pm
Hey,
Within the HomePage.ss template file I placed this code:
<% control MyBlogEntries %>
<div class="newscolumn left">
<h3>$Title</h3>
<p>$Content <br ><a href="$Link">Read the full post …</a></p>
</div>
<% end_control %>What happens using that code is that for however many blog posts I want displayed (set using MyBlogEntries($limit = 2) in HomePage.php) it will loop everything inside the control brackets.
So from there the css is simply that the newscolumns are set width (450px in this case) and the left class simply does float:left (I've recycled this from other code, the newscolumn class is used in the single post view). The CSS and class side of things is very messy I'll be honest, it could be cleaned up to drop it to one class, the project was pushed for time and I haven't had the time to go back and do some house cleaning on the project yet.
Let me know if you are still having problems,
Stewart
-
Re: Blog Posts on HomePage in Columns... Stuck!

8 October 2009 at 1:02am
Hi guys,
I want to manage the number of the letters of the sentence of displayed blog.
How??Please tell me.
-
Re: Blog Posts on HomePage in Columns... Stuck!

8 October 2009 at 1:09am
Sorry
I found it on.
http://silverstripe.org/blog-module-forum/show/254124#post254124
| 1416 Views | ||
|
Page:
1
|
Go to Top |



