1) I have node named news & it has subnode like 2010 & 2011 like
News
> 2010 /* This shows news list */
>> news 1 /* This is news article */
>> news 2 /* This is news article */
> 2011 /* This shows news list */
>> news 1 /* This is news article */
>> news 2 /* This is news article */
I want to show the last 2 articles of the last node on front page .
I dont know how to do it .
Can you please help me in it.
2) I have created generic property document type of home page .I want to apply it on the other templates. I am directly applyinh it but it is not working , then how to do it?
What does the code you're using to achieve this look like? And when you say you want the two last items to appear on the frontpage do you then mean the 2 latest news items from the 2011 branch?
I suppose you have modified the XSLT after the tips you got from Kim, so it's really just the if sentence you should pay notice to in this example. And of course the select statement.
<xsl:for-each select="$currentPage/2011/* [@isDoc and string(umbracoNaviHide) != '1']"> it will mean that it will choose 2011 node even if i have added 2012 node .....or it will change ?
Yes, this will only select from 2011. It will not change by itself.
A good idea is to always add a custom date picker w time property on document types that should contain dates instead of relying on the create and update dates on a document type.
By doing so you can skip use the $currentPage/* [@isDoc and string(umbracoNaviHide) != '1'] expression and then just sort using your date property - then you should get the latest news returned.
You should still use the if sentence, which I showed you in an earlier example and as mentioned above you should sort by the custom date property you have just set.
how to call image using xslt
Hello,
I am having upload control in my document type......i want to call the image uploaded there using xslt ....
how can i do ?
Hello,
More information about media items in xslt is on this page: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia
Cheers,
Bas
Hi vaibhav
Try something like this:
The upload datatype returns the correct path to the image.
/Kim A
Actually i m trying to do this in news feed .....
Here i write some article & upload an image with it .....it should be shown in the list with other articles .......
i am able to show the texts in ti but not able to show images .........
this is my xslt ......
version="1.0" encoding="UTF-8"?>
DOCTYPE xsl:stylesheet [ ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour tagsLib BlogLibrary ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:sort select="@updateDate" order="descending" />
<div id="">
<div id=""><xsl:value-of select="umbraco.library:ReplaceLineBreaks(image)" disable-output-escaping="yes"/>div> /*this is my image*/
<div id="newscontentArea">
<div id=""><xsl:value-of select="umbraco.library:ReplaceLineBreaks(contentHeader)" disable-output-escaping="yes"/>div>
<div id=""><xsl:value-of select="umbraco.library:ShortDate(@updateDate, true(), ' - ')"/>div>
<div><xsl:value-of select="umbraco.library:ReplaceLineBreaks(article)" disable-output-escaping="yes"/>div>
div>
div>
xsl:for-each>
xsl:template>
xsl:stylesheet>
I have node like this
News
>2010
>> article 1
>> article 2
>2009
>>article 1
>>article 2
On click of 2010 node ,both articles inside it should be shown in list with there respective images ......
Okay, so you're in a for-each. Then try changing the image-line to this:
This should work if the upload field has an alias of image.
You might want to check to see if the upload field is not empty, before rendering the img-tag, but that's another thing :)
/Kim A
Thanx Kim,
It all worked for me . You are to good.
You might want to check to see if the upload field is not empty, before rendering the img-tag, but that's another thing :)
How can i do taht also because i may need it after some time.
Hi,
I have some more query here.
1) I have node named news & it has subnode like 2010 & 2011 like
News
> 2010 /* This shows news list */
>> news 1 /* This is news article */
>> news 2 /* This is news article */
> 2011 /* This shows news list */
>> news 1 /* This is news article */
>> news 2 /* This is news article */
I want to show the last 2 articles of the last node on front page .
I dont know how to do it .
Can you please help me in it.
2) I have created generic property document type of home page .I want to apply it on the other templates. I am directly applyinh it but it is not working , then how to do it?
Thanx in advance.
Hi Vaibhav
What does the code you're using to achieve this look like? And when you say you want the two last items to appear on the frontpage do you then mean the 2 latest news items from the 2011 branch?
/Jan
Hi vaihav!
I'm glad your primary problem is now solved.
"You might want to check to see if the upload field is not empty, before rendering the img-tag, but that's another thing :)"
A quick way you can do this is to change the code to something like this:
/Kim A
Thanx Kim for help,
Hi Jan
Yes i want to show 2 latest news items from the 2011 branch.
I have a code for news list which i have given above.Can i do with this thing with it?
I have no idea how to do it .
Please can u help me ?
You need to make a resctritcion in your for-each loop...Something like this for instance...
<xsl:for-each select="$currentPage/2011/* [@isDoc and string(umbracoNaviHide) != '1']">
<xsl:sort select="@updateDate" order="descending" />
<xsl:if test="position() >='2'>
<div id="">
<div id=""><xsl:value-of select="umbraco.library:ReplaceLineBreaks(image)" disable-output-escaping="yes"/>div> /*this is my image*/
<div id="newscontentArea">
<div id=""><xsl:value-of select="umbraco.library:ReplaceLineBreaks(contentHeader)" disable-output-escaping="yes"/>div>
<div id=""><xsl:value-of select="umbraco.library:ShortDate(@updateDate, true(), ' - ')"/>div>
<div><xsl:value-of select="umbraco.library:ReplaceLineBreaks(article)" disable-output-escaping="yes"/>div>
div>
div>
</xsl:if>
xsl:for-each>
I suppose you have modified the XSLT after the tips you got from Kim, so it's really just the if sentence you should pay notice to in this example. And of course the select statement.
Hope this helps.
/Jan
<xsl:for-each select="$currentPage/2011/* [@isDoc and string(umbracoNaviHide) != '1']"> it will mean that it will choose 2011 node even if i have added 2012 node .....or it will change ?
Hi Vaibhav
Yes, this will only select from 2011. It will not change by itself.
A good idea is to always add a custom date picker w time property on document types that should contain dates instead of relying on the create and update dates on a document type.
By doing so you can skip use the $currentPage/* [@isDoc and string(umbracoNaviHide) != '1'] expression and then just sort using your date property - then you should get the latest news returned.
Hope this makes sense.
/Jan
ok i have taken date picker with time ....now wat to do ? ..still question is sam how to get 2 latest news ....
Hi Vaibhav
You should still use the if sentence, which I showed you in an earlier example and as mentioned above you should sort by the custom date property you have just set.
/Jan
is working on a reply...