I'm trying to display Blog Entries inside of a Navigation Dropdown but it wont display the blog entries. If I remove it outside the <% control ChildrenOf(main) %> control it works but not anywhere inside.
Here is the code.
Page.php
<?php
class Page extends SiteTree {
public static $db = array();
public static $has_one = array();
}
class Page_Controller extends ContentController {
public static $allowed_actions = array ();
public function init() {
parent::init();
Requirements::themedCSS('layout');
Validator::set_javascript_validation_handler('none');
}
function LatestBlogEntries($number=4) {
$holder = DataObject::get_one('OurBlogHolder');
return DataObject::get('BlogEntry', "ParentID = {$holder->ID}","Created DESC", false, $number);
}
}
Navigation.ss
<ul id="nav">
<% control ChildrenOf(main) %>
<li class="dropTrigger">
<a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a>
<% if Children %>
<ul id="{$URLSegment}Drop" class="dropdown">
<% control Children %>
<% if ClassName = SolutionsSubHolder %>
<% control Children %>
<li class="{$URLSegment}">
<h2><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode">$MenuTitle.XML</a></h2>
<% if DropdownText %><p>$DropdownText.LimitCharacters(65)</p><% end_if %>
</li>
<% end_control %>
<% else %>
<li class="{$URLSegment}">
<% if DropdownImage %><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><img src="$DropdownImage.URL" alt="" /></a><% end_if %>
<h2><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode">$MenuTitle.XML</a></h2>
<% if DropdownText %><p>$DropdownText</p><% end_if %>
<% if ClassName = OurBlogHolder %>
<ul>
<% control LatestBlogEntries %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul>
<p><a class="arrowLink" href="">Read More</a></p>
<% end_if %>
</li>
<% end_if %>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>