1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » How display all blog tags on home page
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 506 Views |
-
How display all blog tags on home page

10 January 2012 at 8:08am
Hello everyone!
I can't find out on forum, how display all blog tags on home page? Any ideas?
-
Re: How display all blog tags on home page

28 March 2012 at 12:25am
In HomePage.php...
function LatestBlogs() {
return DataObject::get('BlogEntry', 'ShowInSearch=1', 'Date DESC', '', 5);
}This shows the most recent 5 posts, from newest to oldest. Change the last parameter to change the number of posts returned.
Posts with 'Show In Search' unchecked are excluded.In homepage.ss...
<ul>
<% control LatestBlogs %>
<li class="$LinkingMode<% if first %> first<% else_if last %> last<% end_if %>"><a href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul>The classes first & last are added to help with styleing.
Optionally, if you plan on having a lot of blog posts, add a database index to the blog date field to speed up the LatestBlogs function. Add BlogEntryDecorator.php
class BlogEntryDecorator extends DataObjectDecorator {
public function extraStatics() {
return array(
'indexes' => array(
'date' => '(Date)',
)
);
}
}Add to _config.php
Object::add_extension('BlogEntry', 'BlogEntryDecorator');
| 506 Views | ||
|
Page:
1
|
Go to Top |

