Copied to clipboard

Flag this post as spam?

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


  • Martin Vingaard 39 posts 60 karma points
    Feb 08, 2011 @ 13:47
    Martin Vingaard
    0

    Mediapicker & Contentpicker menu issue / help

    ATM I’m having two issues.
    And I think it would help to describe the page structure first.

    Company
                          -Language
                                                -Home
                                                -About Us
                                                -Contact
                                                -Ect
                          -Language
                                                -Home
                                                -.......

    The issues are 

    1.  At the Language node I determine the icon/image and where it should link. But i need this to be recursive, since the menu should remain the same on the subpages.
    But it should be customizable within each Language node.

    2.  Also the link at my img doesn’t work. The href doesn’t refer to anything but the line of code actually.

    The code:

    <?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: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" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">


    <xsl:if test="$currentPage/submenuImage01 != ''">
      <!-- Where it should link -->
      <href="umbraco.library:NiceUrl($currentPage/data[@alias='submenuLink01'], 0)">
      <!-- What img button is loaded -->
        <img src="{umbraco.library:GetMedia($currentPage/submenuImage01,0)/umbracoFile}" />
      </a>
    </xsl:if>



    </xsl:template>

    </xsl:stylesheet>

    I realize that i should use $currentPage/ancestor-or-self for the 1st issue
    or am I wrong?

    Thanks for the help

    /mVingaard

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Feb 08, 2011 @ 15:49
    Rasmus Berntsen
    0

    Hi Martin,

    First of all, are you running version 4.5+? Your XSLT seems to be a mix between the new and old schema... :)

    Ancestor-or-self would be the way to get the property recursively.

  • Martin Vingaard 39 posts 60 karma points
    Feb 08, 2011 @ 16:16
    Martin Vingaard
    0

    Yeh I’m running 4.6.1 to be precise

    It’s my first large project in Umbraco so I’m kind of learning as i go :)

    Allot of the guides online are from the old XSLT so gotta confess, I get confused from time to time.

  • Martin Vingaard 39 posts 60 karma points
    Feb 09, 2011 @ 14:25
    Martin Vingaard
    0

    Shameless bump

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Feb 10, 2011 @ 13:39
    Rasmus Berntsen
    0

    Hi again,

    What I would do is this:

    Create a variable, call it data:

     <xsl:variable name="data" select="$currentPage/ancestor-or-self::language[@isDoc]" />

    You have to replace "language" with the documenttype alias of the language node. The variable above will look for ancestor-or-self of type "language", which is a document and not a property [@isDoc]

    And create two variables more, one for the href and one for the img:

    <xsl:variable name="Img" select="$data/submenuImage01" />
    <xsl:variable name="Link" select="$data/submenuLink01" />

    The variables above uses the data-variable and therefore looks for the two properties at the "language" doc.

    Now you should be able to do something like this:

        <xsl:if test="$Img !='' and $Link !=''">
          <xsl:variable name="ImgLink" select="umbraco.library:NiceUrl($Link)"/>
          <xsl:variable name="imageFromMedia" select="umbraco.library:GetMedia($Img, 0)/umbracoFile" />
          <a href="{$ImgLink}">
            <img src="{$imageFromMedia}" />
          </a>
        </xsl:if>

    The above code only work if: 1. "submenuImage01" is of type Media Picker and 2. "submenuLink01" is of type Content Picker. Try it out. :)

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Feb 10, 2011 @ 13:42
    Rasmus Berntsen
    0

    And please remember to create some cool title- and alt-tags for the image and link. You could add these properties at the language-node and get them like "Img" and "Link"... :)

  • Martin Vingaard 39 posts 60 karma points
    Feb 10, 2011 @ 15:34
    Martin Vingaard
    0

    Thanks for the reply :)
    I will test it tonight or tomorrow at work.

    Im pritty sure i understand the syntax now.

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Feb 10, 2011 @ 15:40
    Rasmus Berntsen
    0

    You could also take a look at this Wikipage, which explains the difference between the old and the new XML schema:

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema

    And some XSLT examples which show the difference:

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema

     

    Good luck! And feel free to reply if it doesn't work...

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 10, 2011 @ 16:32
    Jeroen Breuer
    0

    If you're looking for a media picker with some extra features I've created the Digibiz Advanced Media Picker in which you can do a lot more! You can find a sample on how to use it here: http://screenr.com/TEY.

    Jeroen

  • Martin Vingaard 39 posts 60 karma points
    Feb 14, 2011 @ 08:47
    Martin Vingaard
    0

    Thanks for the Berntsen. Your post was a great help, but it still dosnt fetch the data from the parent page.
    I'm gonna do some troubleshooting later today and see if i can get it fixed.

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Feb 14, 2011 @ 13:59
    Rasmus Berntsen
    0

    Hi Martin,

    Did you receive any kind of errors or did the data just not show?

    Btw. "Thanks for the Berntsen" is a great typo... :D

  • Martin Vingaard 39 posts 60 karma points
    Feb 14, 2011 @ 14:10
    Martin Vingaard
    0

    haha. i was @ a tecture at school. Wasnt concentrating :P

    I got no error while saving. 

    I added a <p>test</p> within the 'if' to see if it got any data. But the para. didnt show.

    i just a hold of 'An introduction to XML and Web Technologies'... It should be a help.

    I worked with C# prior to this, so it should be "easy" to master

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Feb 14, 2011 @ 14:16
    Rasmus Berntsen
    0

    Try to get the values from the two variables then:

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

    and

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

    Any luck?

     

     

  • Martin Vingaard 39 posts 60 karma points
    Feb 15, 2011 @ 18:04
    Martin Vingaard
    0

    Hi, sorry for the late reply.

    Haha what a great typo :P

    Im have my studys this week end got some papers to write, so got off work. But ill spend my evenings figuring this out. And i will reply the second i get some new information.

    Regarding errors i get none, i saved the XLTS with no problems.

    I added a paragraph to the If sentence, saying "test" and it did not show, so i figured that it dosnt read any data.

    Ill try and fix it this Friday at the latest.

    Also i borrowed a book from my former teacher regarding XML and XLTS programming.

     

    Thanks

    /Martin Vingaard

Please Sign in or register to post replies

Write your reply to:

Draft