I am not good at the xslt at the moment and need your guidance.
I have such structure.
-News
- WriterA
- Article of WriterA
- Article of WriterA
- WriterB
- Article of WriterB
- Article of WriterB
and so on...
What I want to achieve is to show only last added article of writers in a list or div everytime I add a new one. The code snippet which I have added in the following finds all child nodes of nodeID 1139 which is the node id of News and brings only 1 item at a time with variable maxItems but this is not what I want to achieve of course...
Perhaps maxItem approach is wrong. To clarify, for example if authorA has several articles at his node, I need to show only the last created one. The process is same for other authors as well.
By the way I am new completely to Umbraco, would you pls guide me how I can add XsltExtension to Umbraco?
If you want the list of the last articles from every author sorted by author this is no problem with xslt. But if you want to have the list sorted by createDate of the article you propably would use the xsltextension.
For a guide how to use XsltExtensions take a look here or take a look into the umbraco.tv series
That was even a big help Thomas btw. As you have just pointed out, I want the list of the last articles from every author sorted by author. Based on my first post, Where should I update code snippet in order to get that output?
To clarify the code: first you are iterating through every writer. For each writer you are starting a new div with class writer. Then you are iterating through all articles of the writer, but you are only using the first article for the output.
List nodes of child node
Hi everyone,
I am not good at the xslt at the moment and need your guidance.
I have such structure.
-News
- WriterA
- Article of WriterA
- Article of WriterA
- WriterB
- Article of WriterB
- Article of WriterB
and so on...
What I want to achieve is to show only last added article of writers in a list or div everytime I add a new one. The code snippet which I have added in the following finds all child nodes of nodeID 1139 which is the node id of News and brings only 1 item at a time with variable maxItems but this is not what I want to achieve of course...
As I understand you correct you want to get a list of articles with max items from each writer but all together sorted by date, right?
In principle this is a perfect senario for LinqToUmbraco. Otherwise I would recommend to implement an XsltExtension like this one
Snippet
Then you can use this extension like this:
hth, Thomas
Hi Thomas,
Perhaps maxItem approach is wrong. To clarify, for example if authorA has several articles at his node, I need to show only the last created one. The process is same for other authors as well.
By the way I am new completely to Umbraco, would you pls guide me how I can add XsltExtension to Umbraco?
If you want the list of the last articles from every author sorted by author this is no problem with xslt. But if you want to have the list sorted by createDate of the article you propably would use the xsltextension.
For a guide how to use XsltExtensions take a look here or take a look into the umbraco.tv series
hth, Thomas
That was even a big help Thomas btw. As you have just pointed out, I want the list of the last articles from every author sorted by author. Based on my first post, Where should I update code snippet in order to get that output?
If you want to sort by author first you can do something like this:
Snippet
As you can see in line 6 the if statement checks if the item you are at is the first in the list you have.
hth, Thomas
To clarify the code: first you are iterating through every writer. For each writer you are starting a new div with class writer. Then you are iterating through all articles of the writer, but you are only using the first article for the output.
hth, Thomas
And if you need a good introduction into xslt with umbraco use the great articles from Doug:
Cheers, Thomas
Thanks for help so far Thomas. It helped a lot to understand the basic of xslt.
Glad I could help, enjoy Umbraco ;-)
is working on a reply...