Copied to clipboard

Flag this post as spam?

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


  • Streety 358 posts 568 karma points
    Jul 28, 2011 @ 12:01
    Streety
    0

    XSLT where statement

    How would you do a join in the XSLT?

    For instance with SQL i would do a a where statement to pull in all records that matched the variable.

    Is this possible in XSLT?

     

    I have a product and I want to associate a manufacturer. So the product is on the many side et al. Could someone point me in the right directions.

    Thank you.

  • Richard 146 posts 168 karma points
    Jul 28, 2011 @ 16:26
    Richard
    0

    One way would be to create a DataType based on ListItem, in the Developer tab. Add the manufacturers to this DataType, and then add this DataType to your Product DocumentType, call it 'manufacturer' say.

    You could then search for the Product nodes that have the value of manufacturer set to the manufacturer that you are interested in, $filterCriteria, like this:

    <xsl:variable name="selectedNodes" select="$currentPage//node [@nodeTypeAlias='NewsItem'][string(data [@alias='umbracoNaviHide']) != '1'][contains(data[@alias='categorisation'],$filterCriteria)]"/>

    "contains" was used in this example as "categorisation" was a checkbox field. But you could change [contains(data[@alias='categorisation'],$filterCriteria)] to [string(data [@alias='manufacturer']) != 'ford']

    Richard

  • Streety 358 posts 568 karma points
    Aug 08, 2011 @ 14:01
    Streety
    0

    Hmm I think I have done what you suggested.

     

    I created a new  Data type "manufacturer picker" set it to Ultimate Picker and set the node to the root of the manufactures in the hierachy.

    Within the product doc type I have included this new data type control.This works just fine.

    However I am a bit confused with the syntax to pull in the Manufacturer logo  ("manufLogo") which is a upload control with the "Manufacturers" doc type.

    I need to match the Manufacturer Name  called "bodyTitle" from the  "Manufacturers" heirarchy to the selected product field "manufacturer" in the products heirarchy, then get the manufLogo path to insert into a img src 

    Where do I setup the filterCriteria?

    I suspect the XSLT needs to traverse the tree until it gets to  manufacturers  and then find a match with the sub nodes that have a matching BodyTitle.

     

    It seems a little backward to be matching varchars when a numeric would be much faster...or is that not really a consideration? 

  • Richard 146 posts 168 karma points
    Aug 09, 2011 @ 10:57
    Richard
    0

    What value is being stored in the product doc type with the Ultimate Picker field, that has the manufacturer picker. If you do the following, what output do you get? With the old schema (what version of Umbraco/schema are you using?):

    Manu: <xsl:copy-of select="./data[@alias='manufacturer']"/><br/>

    new schema:

    Manu: <xsl:copy-of select="./manufacturer"/><br/>


    Richard

Please Sign in or register to post replies

Write your reply to:

Draft