Hi,
I'm trying to create a number limited list of 'latest blog posts' in my side bar, that appears in all pages (Blog and non-blog) of a site. The listing is to have the blog title, a number limited synopsis of the content and a link.
However, it appears that I can't call $Content.LimitWordCountXML(10) directly... Instead, I have use use <% with Content %>$LimitWordCountXML(10)<% end_with %>.
Here is my code.
In Page_Controller - Page.php:
function LatestPosts($postLimit=3) {
$latestPosts = null;
$blogHolderAvailable = BlogHolder::get();
if ($blogHolderAvailable) {
$latestPosts = BlogEntry::get()->sort("Date", "ASC")->limit($postLimit);
}
return $latestPosts;
}
Template Snippet - doesn't work
<ul>
<% loop $LatestPosts %>
<li class="latestPostSynopsis">
<h4>$MenuTitle</h4>
<p>$Content.LimitWordCountXML(10)...</p>
<a href="$Link" title="<% _t('VIEWFULL', 'View full post titled -') %> '$Title'">Read More</a>
</li>
<% end_loop %>
</ul>
The above template outputs:
<li>
<h4>MyMenu1</h4>
<p>This is the full blog content that has been output instead of being word limited to 10.LimitWordCountXML(10)...<p>
<a href="/blog1" title="Full blog1 title">Read More</a>
</li>
When I replace $Content.LimitWordCountXML(10) with <% with Content %>$LimitWordCountXML(10)<% end_with %>, it works correctly.
Is it not possible to pass in parameters to a sub-property the way I have done it? Do I need to enter into the scope of the property ($Content) using <% with %>to call methods and pass parameters?
Thank you.
VWD.