Thanks for the reply, I had been working on this for a few hours this
afternoon and that was the solution I came up with. Thanks for the 'order by
jcr:created'. I hadn't managed to get that to work as I hadn't been using
'jcr:created' (hence I have Collections.reverse(contents) instead). Here is
some of the code I used in case it is of use to someone:
WebContext webContext = (WebContext)
FactoryUtil.newInstance(WebContext.class);
webContext.init(request , response ,
request.getSession().getServletContext());
MgnlContext.setInstance(webContext);
websiteHierarchyManager = webContext.getHierarchyManager("website");
QueryManager queryManager = websiteHierarchyManager.getQueryManager();
String xPathQuery = "/jcr:root//element(* , mgnl:content)";
Query query = queryManager.createQuery(xPathQuery , Query.XPATH);
ArrayList contents = (ArrayList) query.execute().getContent();
Collections.reverse(contents);
int counter = 0;
Iterator iterator = contents.iterator();
while(iterator.hasNext() && counter < numberOfSummaries){
Content content = (Content) iterator.next();
String pageHeading = content.getNodeData("pageHeading").getString();
String pageName = content.getHandle();
boolean hideInNav = new Boolean((String)
content.getNodeData("hideInNav").getString()).booleanValue();
// Do other stuff in here.
}
gregoryjoseph wrote:
>
>
>
> On Jul 22, 2009, at 1:35 AM, doahh wrote:
>
>>
>>
>> Is there a way to get the most recently created page in the
>> repository? I am
>> currently using this to get a particular page ("/index" in this case):
> <...>
>>
>> and am not sure if it can be modified to to get the most recently
>> created
>> page.
>
> Over the whole workspace ?
> You'd need to execute a query along the lines of select * from
> mgnl:content (where clause here if needed...) order by jcr:created
> desc and get the first result.
>
> hth,
>
> -g
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------
>
>
>
--
View this message in context:
http://www.nabble.com/Is-it-possible-to-get-the-most-recently-created-page-tp24597556p24616136.html
Sent from the Magnolia - User mailing list archive at Nabble.com.
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------