Rank: Newbie
Joined: 8/18/2008 Posts: 21 Location: bangalore
|
Hi All,
As I want to get corresponding image of a particualr product,I tried a lot but i didnt find any solution,anyone can help me plz? Actually the Issue is,For suppose if we have a list of products i.e., cars like Ford,Esteem,BMW,Honda City,we have to get the respective images of the products.
as my code is:
<?xml 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:msxsl="urn:schemas-microsoft-com:xslt" xmlns:math="urn:schemas-hizi-nl:math" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" exclude-result-prefixes="msxml Exslt.ExsltMath Exslt.ExsltStrings math umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="numberOfItems" select="count($currentPage/ancestor-or-self::root//node)"/> <!--count of total pages--> <xsl:variable name="ItemSeperator" select="1"/>
<msxml:script language="JavaScript" implements-prefix="math"> function random(numDie,numMax,numMin){ if (numMin==null){numMin=1;} var sum=0; for (var index=0;index<numDie;index++){ sum+=Math.floor(Math.random()*(numMax-numMin) + numMin); } return "" + sum; } function floorme(numFloor){ return "" + Math.floor(numFloor); } </msxml:script> <xsl:variable name="parent" select="umbraco.library:GetMedia(1040, false())" /> <xsl:variable name="random" select="math:random(1, count($parent/node)+1, 1)"/>
<xsl:template match="/"> <div class="Layout_Content_Holder"> <!-- The fun starts here --> <xsl:for-each select="$currentPage/ancestor-or-self::root//node[string(data [@alias='ShowInProducts']) = '1']"> <xsl:sort select="@createDate" order="descending"/> <xsl:if test="position() <= $numberOfItems">
<div class="IntroBox_3"><div class="YSpace" style="height: 5px; "> </div> <a><img src="../media/2946/ford.jpg" alt="images" /></a> <div class="XSpace" style="height: 13px; "> </div> <div class="YSpace" style="height: 5px; "> </div> <div class="XSpace" style="height: 13px; "> </div> <div style="height: 39px;float : left; " class="ReplaceText_3 Minus_35" onmouseover="this.className='ReplaceText_4 Minus_35'" onmouseout="this.className='ReplaceText_4 Minus_35'" onclick="location.href='{umbraco.library:NiceUrl(@id)}'"> <a href="{umbraco.library:NiceUrl(@id)}" style="font-size: 34px; "><xsl:value-of select="@nodeName"/></a> </div> <div class="XSpace" style="height: 5px; "> </div>
<div class="XSpace"> </div> <div style="float: left; height: 25px; " class="White_Arrow_Small ReplaceText_4 Minus_5" onmouseover="this.className='Red_Arrow_Small ReplaceText_4 Minus_5'" onmouseout="this.className='White_Arrow_Small ReplaceText_4 Minus_5'" onclick="location.href='{umbraco.library:NiceUrl(@id)}'"> <a href="{umbraco.library:NiceUrl(@id)}" style="font-size: 20px; ">Experienc<div>e</div></a> </div> </div> <xsl:if test="position() mod 3 = 0"> <div class="XSpace" style="height: 5px; "> </div> <div class="HrBox"> </div> <div class="XSpace" style="height: 13px; "> </div> </xsl:if> </xsl:if>
</xsl:for-each> </div>
</xsl:template>
</xsl:stylesheet>
if we specify one image address then it will work fine,but it has to pick from media according to that product
Thanks In Advance
regards, Yamuna
Thanks & Regards, Ammu
|
 Rank: Fanatic
Joined: 7/19/2006 Posts: 496 Location: Göteborg, Sweden
|
Hmm... I'm not sure that I fully understand your task but... You could create a doc type "modelImages" and simply create one property for each car model. This property could be an upload or a node picker. To show the images just append the correct property as href for an upload property or use getmedia for the nodeID if you used a node picker.. // :) Kalle
" - Yeah I'd like to share your point of view, as long as it's my view too... ( http://www.d-a-d.dk/lyrics/pointofview)
|
Rank: Newbie
Joined: 8/18/2008 Posts: 21 Location: bangalore
|
Hi Kalle,
Thanks for your solution. I tried this earlier,unfortunately it is not working for me.
As I have to pass, source of an image in xslt to get the image.If we pass one particular id it will work fine but i want to pass image path which i specified in simple editor.
In my code i had specified like this:
<a> <img src="$currentPage/ancestor-or-self::root//node[string(data[@alias='ProductsMenuImage'])]" alt="images"/> </a>
In which "ProductsMenuImage" is a simpleeditors name,i want to get the data or path which i specified in that content as source.Can you tell me how to get this plz?
Can you tell me,what I am missing here,to get the required solution?
Thanks & Regards, Ammu
|
 Rank: Enthusiast
Joined: 7/2/2008 Posts: 34 Location: India
|
Quote: <xsl:choose> <xsl:when test="((data [@alias = 'ProductsMenuImage'])!= '')"> <img><xsl:attribute name="src"> <xsl:value-of select="data [@alias = 'ProductsMenuImage']" /> </xsl:attribute> </img> </xsl:when> <xsl:otherwise> <!-- if you dont have the image for that product and you just wish to show some image there--> <img src="/media/18497/photocomingsoon_thumb.jpg" /> </xsl:otherwise> </xsl:choose> </a>
Hope this works... Cheers, Amritanshu Good judgment comes from experience, and often experience comes from bad judgment. So experience is simply the name we give our mistakes...
|