Copied to clipboard

Flag this post as spam?

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


  • Michael Jensen 29 posts 98 karma points
    Oct 28, 2015 @ 14:00
    Michael Jensen
    0

    XSLT macro not working.

    Hey,

    i normely use version 6 but need to start on 7 so i rann in to a problem..

    i cant seam to get my image slider macro to work.

    this is who i hvad made it but i dos not show the image..

    this is wath i think is to be, but no go.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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:Examine="urn:Examine" 
        exclude-result-prefixes="msxml umbraco.library Examine ">
    
    <xsl:output method="xml" omit-xml-declaration="yes" />
    
    <xsl:param name="currentPage"/>
    
    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="source" select="/macro/source"/>
    
    <xsl:template match="/">
    
    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
        <li data-transition="random" data-slotamount="7" data-masterspeed="500" data-saveperformance="on" data-title="@nodebilledeNavn">
            <img src="@nodeimage"  alt="@nodealtText" data-bgposition="center top" data-bgfit="cover" data-bgrepeat="no-repeat"/>
            <div class="tp-caption default_bg large sfr tp-resizeme"
             data-x="0"
             data-y="30" 
             data-speed="600"
             data-start="1200"
             data-end="9400"
             data-endspeed="600">"@nodecaptationTekst"
            </div>
        </li>   
    </xsl:for-each>
    </ul>
    
    </xsl:template>
    
    </xsl:stylesheet>
    

    this is my old macro.

    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @{
        var startNodeID = Parameter.nodeId;
    }
    
    @if (startNodeID != null)
    {   
        @* Get the start node as a dynamic node *@
        var startNode = Library.NodeById(startNodeID);
    
        if (startNode.Children.Where("Visible") .Any())
        {       
            <ul class="slides">
                @foreach (var page in startNode.Children.Where("Visible"))
                {
            <li data-transition="random" data-slotamount="7" data-masterspeed="500" data-saveperformance="on" data-title="@page.billedeNavn">
                    <img src="@page.image"  alt="@page.altText" data-bgposition="center top" data-bgfit="cover" data-bgrepeat="no-repeat"/>
                    <div class="tp-caption default_bg large sfr tp-resizeme"
                     data-x="0"
                     data-y="30" 
                     data-speed="600"
                     data-start="1200"
                     data-end="9400"
                     data-endspeed="600">"@page.captationTekst"
                    </div>
            </li>
                }
            </ul>
        }
    }
    

    Michael

  • Steve Morgan 1349 posts 4459 karma points c-trib
    Oct 29, 2015 @ 12:54
    Steve Morgan
    0

    Been a while since I've done some XSLT but am I right in thinking that source is a media picker that's being passed in. This will / should be just a nodeId so you need to get the image ... some of the code below should point you in the right direction. I'd recommend you output the $source and check it is an ID or csv of IDs.

    An single image example:

     <xsl:variable name="media" select="umbraco.library:GetMedia($source)" />
    
     <xsl:if test="$media">
        <xsl:variable name="url" select="$media/umbracoFile" />
        <xsl:variable name="width" select="$media/umbracoWidth" />
        <xsl:variable name="height" select="$media/umbracoHeight" />
        <img src="{$url}" width="{$width}" height="{$height}" />
     </xsl:if>
    

    A multi image example - shamlessly copied from: http://stackoverflow.com/questions/29327430/debugging-multiple-media-picker-umbraco-xslt-macro

    <xsl:variable name="linkidlijst1" select="$contentfolder" />
    <ul class="img-list">
    
      <xsl:variable name="nodeIds" select="umbraco.library:Split($linkidlijst1, ',')" />
      <xsl:for-each select="$nodeIds/value">
        <li>
          <xsl:variable name="medianummer" select="." />
          <xsl:if test="$medianummer != ''">
            <xsl:variable name="media" select="umbraco.library:GetMedia($medianummer, 'false')" />
            <xsl:if test="$media">
              <xsl:variable name="url" select="$media/umbracoFile" />
              <xsl:variable name="width" select="$media/umbracoWidth" />
              <xsl:variable name="height" select="$media/umbracoHeight" />
              <xsl:variable name="alt" select="umbraco.library:GetMedia($medianummer, 'false')/@nodeName" />
              <xsl:if test="$url != ''">
                <img src="{$url}" alt="{$alt}" width="{$width}" height="{$height}" />
              </xsl:if>
            </xsl:if>
          </xsl:if>
        </li>
      </xsl:for-each>
    </ul>
    
Please Sign in or register to post replies

Write your reply to:

Draft