Copied to clipboard

Flag this post as spam?

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


  • Laura Holland 82 posts 103 karma points
    Jan 05, 2011 @ 17:46
    Laura Holland
    0

    Media section - Best way to manage documents?

    I'm having trouble deciding on the best way to implement the following media management scenario (which is probably a common one):

    1. I want my Umbraco users to be able to upload new documents and images directly in the Content area, and I want these uploaded items to display in the Media section under the appropriate folders (images in the images sub folder, documents in the documents sub folder, etc).

    2. When my users upload a new document (mostly PDF brochures) in the Content area, I want the live site to display a stylized list of links to these documents. My users can delete and upload new files as they see fit from the Content area, but won't have control over styles (e.i. they won't be using a rich text editor).

    3. If the users try and delete or overwrite an item from the Media folder that is currently in use on the site, a warning notification would pop up... This isn't strictly necessary, but would be a useful, I think.

    What's the best way to make steps 1 + 2 happen, and maybe 3?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 05, 2011 @ 18:34
    Jan Skovgaard
    0

    Hi LauraI

    1) I'm not sure about the best way to handle this using the API. Hopefully someone else has a good idea for a solution :-)

    2) This is a job for a XSLT macro where you loop through the selected folder containing the media and in the XSLT you define the HTML structure. Then you can easily style it any way you want to using CSS. If you need to make icons so it's easy to see what kind of document the link is pointing too you you can target the file type with CSS as well. And if you need to bulletproof it you can add a class using the XSLT containing the name of the file-type.

    3) I think this is a matter of doing a check to see if the current property has a value. If it has, display a warning.

    Hope this makes sense

    /Jan

  • Laura Holland 82 posts 103 karma points
    Jan 05, 2011 @ 21:34
    Laura Holland
    0

    Thanks Jan. I set up an ultimate picker and it's working well, but I'm not having any luck with the XSLT output. I'm using this as a template:

    http://blog.leekelleher.com/2009/09/08/umbraco-ultimate-picker-xslt-example/

    I think it's not working because I'm linking to Media rather than content pages. Also, I want the output to list the "Name" variable from the Media section, not the actual file name.. Is this possible?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 05, 2011 @ 22:00
    Jan Skovgaard
    0

    Hi Laura

    It is possible to use the ultimate picker to select images and fetch them and their properties using XSLT.

    How have you setup the ultimate picker? (Have you remembered to give it a specific folder id (node id) where it needs to display the nodes from) - Dependent on how you want to setup things it's possible you will need more instances of the ultimate picker.

    What version of Umbraco are you using? If you're using umbraco 4.5.x I recommend that you install uComponents and use the "Multi-node tree-picker" datatype, which is a bit more flexible and configurable. (Here you'll also need to specify the node id where to fetch the content from)

    /Jan

  • Laura Holland 82 posts 103 karma points
    Jan 05, 2011 @ 23:59
    Laura Holland
    0

    I'm running Umbraco 4.5.2. Using ultimate picker, I specified a node, and when I run it directly it will display the id numbers, seperated by a comma, of the correct media files (PDF files). Now, of course, I need to format it to display the "name" attribute of the media file, rather than the file path or id, as an unordered list.. so I set up a macro using the XSLT code, and embedded it into the page template. But no luck... I'm not brilliant in the XSLT department, I have to admit.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 06, 2011 @ 00:23
    Jan Skovgaard
    0

    Hi Larua

    Ok - since the example on Lee's blog is based on content nodes it makes sense that you only get the id's and nothing else.

    What you need to do is use the umbraco.library:GetMedia() extension to get the image files XML where you can retrieve the information you need.

    From the top of my head you should be able to get the XML using this example - making it easier to see what elements and attributes to match in you template. This gives you a textarea of each id - I think you should be able to handle it from here...otherwise just let us know :-) (The example could probably be more well-written but as stated this is from the top of my head and quick'n'dirty)

    <xsl:variable name="images" select="umbraco.library:Split($currentPage/field,',')" />
      
        <xsl:for-each select="$images//value">
             <xsl:variable name="properties" select="umbraco.library:GetMedia($images//value,0)" />
          
           <textarea>
             <xsl:copy-of select="$properties" />
           </textarea>
        </xsl:for-each>



    I hope this helps.

    /Jan

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 06, 2011 @ 00:27
    Jan Skovgaard
    0

    Please note that "field" in the above example refers to my property for the ultimate picker - you should of course use the property name of your ultimate picker.

    And do also note that the example you found on Lee's blog is using the legacy XML schema (The old XML syntax, which is used in older version than Umbraco 4.5) - So if you're running 4.5 there is a new XML syntax to be aware of. Examples on the "GetMedia" extension cover both the new and the old syntax. If you're running an older version of Umbraco the XML syntax on Lee's blogpost makes sense.

    Hope this makes sense? :-)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft