Custom Menu setting StartingPoint and Filter Nodetype


(kemal özkan) #1

Hi,
I want to make a little section in a sidebar “Latest news” it should filter last 5 News (I have defined a Datetime field in a custom node which extends the page). But the problem is I can not force the menu to pick the nodes under news/ which are derived from NewsEntry.
here is my menu structure

  • Home
  • News
    – First news entry (vendor.name:NewsEntry)
    – Second news entry(vendor.name:NewsEntry)
    – Wrong placed Page (Neos.NodeTypes:Page)

Here is the fusion file

“Latestnews” element, extending the default “Menu”

prototype(Site:LatestNews) < prototype(Neos.NodeTypes:Menu) {

templatePath = 'resource://vendor.name/Private/Templates/NodeTypes/LatestNews.html'
#itemCollection = ${q(site).filter('[instanceof vendor.name:NewsEntry]').get()}
itemCollection = ${q(site).add(q(site).children('[instanceof vendor.name:NewsEntry]')).get()}

startingPoint = ${q(site).children('[uriPathSegment="news"]').get(0)}
entryLevel = 3 #i tried all numbers from 1- to 10, 3 was the actual state while I copied this 
maximumLevels = 10

}
Thank you in advance.


(kemal özkan) #2

An unbeautiful solution : Check the node type in html file with
<f:if condition="{item.node.nodeType.name} == ‘vendor.name:NewsEntry’">

–do your stuff

</f:if>

I will be very happy if some one comes with a better solution.

Thank you


(kemal özkan) #3

Solved:
${q(site).find(’[instanceof vendor.site:NewsEntry]’).sort(‘publishingDate’,‘DESC’).get()}