I'm completely new to umbraco and i'm already stucked. I want to create xml file that holds the information about page name, link to that page, description and a an image.
This is a simple structure of that xml file. For simplicity it has only one node for now.
<node id="1" nodeName="destination"> <data alias="navName"> <![CDATA[Lighthouses]]> </data> <data alias="description"> <![CDATA[Spend unique holidays in the middle of the Adriatic sea ? Book a lighthouse!]]> </data> <data alias="link"> <![CDATA[/authentic-croatia/lighthouses.aspx]]> </data> <data alias="image"> <![CDATA[/media/images/Lighthouses.jpg]]> </data> </node>
What I don't know is how to read this from the xslt. Where do I put the xml file regarding of the xslt file? I have put it in the same dir as the xslt file. Is this the right thing to do?
It seems to me you want to display details from nodes in your content. You don't need to access an external xml for that, you can access the umbraco xml from within the xslt. Just choose the template "subpages from a changeable source" or the template "subpages from the current page" to get a grasp of how the XSLT will list the sub pages.
The sub pages are actually all xml nodes which you can further drill down to in your xslt. Use the "visualise xslt" function on the right top of your xlst page and choose a node on which you can perform the xslt. If you use a "<xsl:copy-of select="."/> you will copy the xml of the current node you're on. If you do that under your for-each, you will list the xml for each node under your current (or chosen one). Please note that you might need to encode the result (checkbox on visualize xslt).
For example, if you have a document type (in umbraco 4.5.2) of type "destination" as in your example, you could
- do a foreach of $currentpage/destination
in the foreach do a xsl:value-of select="./description" etc.
I hope this might help you getting on the right track, if it's a bit too cryptic let me know.
Thank you, I have managed to create links based on the document type properties as you proposed.
Now I'm stucked as I dont know how to show the thumbnail image with the link. What is the right way to do this?
Also there is another problem, each of this pages will have 4 different languages, so I don't know is this the right way to do this. Do I need to have different page for each one of these language or I can do this dynamicaly?
For a solution on multiple language sites there are different approaches. Generally in the Umbraco community people will use a different sub or child domain (yourdomain.com/en; yourdomain/nl etc) and build several homepage nodes with different host headers (right click on a homepage node and set the host header for your domain and language). More about multi language sites can be found in this excellent tutorial (subscription of 19€ to Umbraco TV required): http://umbraco.org/help-and-support/video-tutorials/umbraco-fundamentals/running-multiple-sites/structure,-domains-and-languages. If you don't want to pay for the subscription just search on this forum for some approaches.
To show a thumbnail: that depends on the data type you used. If it's a media picker, you'll want to use some umbraco library extension in your xslt. Just click the button for the xslt:value-of, select extensions, select umbraco library and select the GetMedia. I think you'll get the hang of how to do that pretty quickly. Otherwise just search the forum for GetMedia.
If it's a upload data type, it might be a bit different. So if you still need some advise reply with the exact data type (and/or render control) you use.
It might be useful if you would post your current XSLT as well (use the code block function).
<!-- The fun starts here --> <ul> <xsl:for-each select="$currentPage/ACDestinations [@isDoc and string(umbracoNaviHide) != '1']"> <div class="Izdvojeno" id="Hoteli"> <img> <xsl:attribute name="src"> <xsl:value-of select="./thumbnail" /> </xsl:attribute> </img> <a href="{umbraco.library:NiceUrl(@id)}"> <h3> <xsl:value-of select="@nodeName" /></h3> <xsl:value-of select="./description" /> </a> </div> </xsl:for-each> </ul> </xsl:template>
</xsl:stylesheet>
As you can see I try to fill the path to the image by stating the './thumbnail' property but nothing happens as I dont' know where do I put these images.
xslt:value-of of the thumnail property won't do you much good.
I would probably go with a html img build up from properties from your thumbnail field.
You should do a copy-of first to see what kind of xml lurks behind this "thumbnail" field you've got; but to my opinion this will probably do the trick:
reading xml file with xslt
Hi,
I'm completely new to umbraco and i'm already stucked. I want to create xml file that holds the information about page name, link to that page, description and a an image.
This is a simple structure of that xml file. For simplicity it has only one node for now.
<node id="1" nodeName="destination">
<data alias="navName">
<![CDATA[Lighthouses]]>
</data>
<data alias="description">
<![CDATA[Spend unique holidays in the middle of the Adriatic sea ? Book a lighthouse!]]>
</data>
<data alias="link">
<![CDATA[/authentic-croatia/lighthouses.aspx]]>
</data>
<data alias="image">
<![CDATA[/media/images/Lighthouses.jpg]]>
</data>
</node>
What I don't know is how to read this from the xslt. Where do I put the xml file regarding of the xslt file? I have put it in the same dir as the xslt file. Is this the right thing to do?
Please any help is appreciated.
Hi,
It seems to me you want to display details from nodes in your content. You don't need to access an external xml for that, you can access the umbraco xml from within the xslt. Just choose the template "subpages from a changeable source" or the template "subpages from the current page" to get a grasp of how the XSLT will list the sub pages.
The sub pages are actually all xml nodes which you can further drill down to in your xslt. Use the "visualise xslt" function on the right top of your xlst page and choose a node on which you can perform the xslt. If you use a "<xsl:copy-of select="."/> you will copy the xml of the current node you're on. If you do that under your for-each, you will list the xml for each node under your current (or chosen one). Please note that you might need to encode the result (checkbox on visualize xslt).
For example, if you have a document type (in umbraco 4.5.2) of type "destination" as in your example, you could
- do a foreach of $currentpage/destination
in the foreach do a xsl:value-of select="./description" etc.
I hope this might help you getting on the right track, if it's a bit too cryptic let me know.
Kind regards,
/HFS
If you're looking for a way to export existing nodes as xml, there are packages that can do that:
http://our.umbraco.org/projects/website-utilities/eyecatch-xml-export
Thank you, I have managed to create links based on the document type properties as you proposed.
Now I'm stucked as I dont know how to show the thumbnail image with the link. What is the right way to do this?
Also there is another problem, each of this pages will have 4 different languages, so I don't know is this the right way to do this. Do I need to have different page for each one of these language or I can do this dynamicaly?
For a solution on multiple language sites there are different approaches. Generally in the Umbraco community people will use a different sub or child domain (yourdomain.com/en; yourdomain/nl etc) and build several homepage nodes with different host headers (right click on a homepage node and set the host header for your domain and language). More about multi language sites can be found in this excellent tutorial (subscription of 19€ to Umbraco TV required): http://umbraco.org/help-and-support/video-tutorials/umbraco-fundamentals/running-multiple-sites/structure,-domains-and-languages. If you don't want to pay for the subscription just search on this forum for some approaches.
To show a thumbnail: that depends on the data type you used. If it's a media picker, you'll want to use some umbraco library extension in your xslt. Just click the button for the xslt:value-of, select extensions, select umbraco library and select the GetMedia. I think you'll get the hang of how to do that pretty quickly. Otherwise just search the forum for GetMedia.
If it's a upload data type, it might be a bit different. So if you still need some advise reply with the exact data type (and/or render control) you use.
It might be useful if you would post your current XSLT as well (use the code block function).
/HFS
ok here is the xslt code.
As you can see I try to fill the path to the image by stating the './thumbnail' property but nothing happens as I dont' know where do I put these images.
xslt:value-of of the thumnail property won't do you much good.
I would probably go with a html img build up from properties from your thumbnail field.
You should do a copy-of first to see what kind of xml lurks behind this "thumbnail" field you've got; but to my opinion this will probably do the trick:
<xsl:if test="./thumbnail">
<xsl:variable name="url" select="./thumbnail/umbracoFile" />
<xsl:variable name="width" select="./thumbnail/umbracoWidth" />
<xsl:variable name="height" select="./thumbnail/umbracoHeight" />
<xsl:variable name="alt" select="./thumbnail/altText" />
<img src="{$url}" width="{$width}" height="{$height}" alt="{$alt}" />
</xsl:if>
is working on a reply...