Copied to clipboard

Flag this post as spam?

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


  • Jeremy Mahieu 5 posts 50 karma points
    Jun 30, 2014 @ 14:33
    Jeremy Mahieu
    0

    Media folder name to node id

    Hello, I'm using umbraco 7.1.4, trying to follow this example and I am stuck with something.

    I want to pick a media folder and then list all images in that folder. In this version of Umbraco the only solution to me seems to have a macro with a Textbox parameter (alias albumFolder).

    I then want to use this parameter like this: 

    <xsl:variable name="images" select="$currentPage/albumFolder"/>

    But I cannot get this to work. There is no reference in the whole xml doc currentPage to this folder. What am I doing wrong?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 30, 2014 @ 15:31
    Dennis Aaen
    0

    Hi Jeremy and welcome to our,

    I could see from the link that you have posted, is the old schema, therefor I think that you should take a look at this like. This list all the image from a folder using the new XML schema.

    http://our.umbraco.org/wiki/how-tos/xslt-useful-tips-and-snippets/list-images-from-mediafolder-in-umbraco-45-plus

    Hope this helps,

    /Dennis

  • Jeremy Mahieu 5 posts 50 karma points
    Jun 30, 2014 @ 15:42
    Jeremy Mahieu
    0

    The problem is that my &currentPage does not have the media folders in it. Therefor it cannot retrieve the nodeIDs.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jun 30, 2014 @ 16:04
    Dennis Aaen
    0

    Okay Jeremy,

    What if you add a property to you document type, with a alias of albumFolder and the data type should be media picker, and when you have done that add this code to your XSLT file.

    <?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"
     exclude-result-prefixes="msxml umbraco.library">

      <xsl:output method="xml" omit-xml-declaration="yes"/>
      <xsl:param name="currentPage"/>
      <xsl:template match="/">

        <xsl:variable name="images" select="$currentPage/albumFolder"/>

          <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($images, true())"/>

          <xsl:for-each select="$mediaItems/Image">
            <xsl:variable name="picFile" select="umbracoFile"/>
            <div class="thumb">
                <img>
                  <xsl:attribute name="src">
                    <xsl:value-of select="$picFile"/>
                  </xsl:attribute>
                </img>

              </xsl:element>

            </div>

          </xsl:for-each>

      </xsl:template>
    </xsl:stylesheet>

    After that insert the maco in your template where you want the images to show up. After you have added the macro to the template then go back to Umbraco and on one of the pages of the document type where you added the new property, then choose a folder from the media section.

    As you can see the file are usig one of the many library methods called GetMedia. You can find the documentation here:

    http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    And for other library methods, aswell.

    http://our.umbraco.org/wiki/reference/umbracolibrary

    Since you maybe are new to Umbraco i would provide some good resoruces to start get the basic concepts of Umbraco since it´s just a shall or a framework if you want. If you don´t have installed any starter kits. And therefor you need to bulid up the backoffice so it suit your customer needs.

    Here are some good documentation on how to work with Umbraco:

    http://our.umbraco.org/documentation/Using-Umbraco/Creating-Basic-Site/

    Here are some good basic video turtorials on how to work with Umbraco:

    http://umbraco.tv/videos/umbraco-v7/implementor/

    Since you are using the Umbraco 7.1.4, there by default are running MVC, you could consider to do the same but instead of using XSLT, then use Razor. If you are doing that I think that you use create a thread in the razor space on this forum, and then just explain that you was started with XSLT; but I said that you should consider doing in Razor.

    Hope this make sense and helps, in some way.

    /Dennis

  • Jeremy Mahieu 5 posts 50 karma points
    Jul 01, 2014 @ 10:06
    Jeremy Mahieu
    0

    Yes I see now, using the property of the document type I can select the mediaFolder type. However I want the property to be in the macro, and in the macro the choise of datatype for the properties is much more limited.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 01, 2014 @ 11:14
    Dennis Aaen
    0

    Hi Jeremy

    Okay in this case, I think that you should choose the single media picker. With this you should also be able to choose a folder.

    Hope this helps.

    /Dennis

  • Jeremy Mahieu 5 posts 50 karma points
    Jul 01, 2014 @ 11:18
    Jeremy Mahieu
    0

    No, you have to choose an actual image in the case of a single media picker. So is there no solution to go from a string with the name of the folder, to the ID of the folder? The problem is that I cannot search to find the folder, because the media folders are not listed in $currentPage. Is there some other location where it gives an overview of all mediaFolders?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 01, 2014 @ 19:11
    Dennis Aaen
    0

    Hi Jeremy,

    I think that you can use the numeric in the macro as the parmeter datatype there you can add the id of the folder with the images that you want to display

    Hope this helps,

    /Dennis

  • Jeremy Mahieu 5 posts 50 karma points
    Jul 02, 2014 @ 16:04
    Jeremy Mahieu
    0

    It helps but all this does not exactly solve it. Thank you anyway.

  • Harish 15 posts 74 karma points
    Nov 20, 2014 @ 17:04
    Harish
    0

    Hi 

    I am having umbraco 6.1.6 version, and insatalled ezsearch package.

    Can any one help me out,  to exclude folder names, .png, .jpg extensions etc from ezsearch result set.......

    i need to retrive content(pages) and some media type (like .doc, .pdf )  only.

    Now when I am searching I am getting pics, folder name, which I dont want to show it in ezsearch result.

    Thanks in advance.

Please Sign in or register to post replies

Write your reply to:

Draft