Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • vaibhav 119 posts 139 karma points
    Mar 18, 2011 @ 10:18
    vaibhav
    0

    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 ?

  • Bas Schouten 135 posts 233 karma points
    Mar 18, 2011 @ 10:21
    Bas Schouten
    0

    Hello,

    More information about media items in xslt is on this page: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    Cheers,

    Bas

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 18, 2011 @ 10:21
    Kim Andersen
    0

    Hi vaibhav

    Try something like this:

    <xsl:value-of select="$currentPage/aliasOfUploadField" />

    The upload datatype returns the correct path to the image.

    /Kim A

  • vaibhav 119 posts 139 karma points
    Mar 18, 2011 @ 11:46
    vaibhav
    0

    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 ......

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 18, 2011 @ 11:52
    Kim Andersen
    1

    Okay, so you're in a for-each. Then try changing the image-line to this:

    <div id=""><img src="{./image}" alt="" /></div>        /*this is my image*/

    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

  • vaibhav 119 posts 139 karma points
    Mar 21, 2011 @ 06:45
    vaibhav
    0

    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.

  • vaibhav 119 posts 139 karma points
    Mar 21, 2011 @ 08:03
    vaibhav
    0

    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.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 21, 2011 @ 08:06
    Jan Skovgaard
    0

    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

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 21, 2011 @ 08:34
    Kim Andersen
    0

    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:

    <xsl:if test="./image != ''">
    <
    div id=""><img src="{./image}" alt="" /></div> /*this is my image*/
    </xsl:if>

    /Kim A

  • vaibhav 119 posts 139 karma points
    Mar 21, 2011 @ 11:10
    vaibhav
    0

    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 ?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 21, 2011 @ 11:59
    Jan Skovgaard
    0

    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() &gt;='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

  • vaibhav 119 posts 139 karma points
    Mar 21, 2011 @ 18:25
    vaibhav
    0

    <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 ?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 21, 2011 @ 19:05
    Jan Skovgaard
    0

    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

     

  • vaibhav 119 posts 139 karma points
    Mar 22, 2011 @ 08:38
    vaibhav
    0

    ok i have taken date picker with time ....now wat to do ? ..still question is sam how to get 2 latest news ....

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 22, 2011 @ 22:25
    Jan Skovgaard
    0

    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

  • Daniel Dosanjh 1 post 21 karma points
    May 18, 2013 @ 19:45
    Daniel Dosanjh
    0
Please Sign in or register to post replies

Write your reply to:

Draft