Copied to clipboard

Flag this post as spam?

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


  • Fergus Davidson 309 posts 586 karma points
    Mar 20, 2010 @ 14:13
    Fergus Davidson
    0

    update media problems - can't access additional properties

    hi

    i should start out by saying that i am not familiar with .net to any degree, and so forgive me if my question is a bit on the simple/obvious side.

    i have added a couple of properties to my default media 'file' type. a title and a description BUT I CAN'T ACCESS THEM.

    i want to be able to execute a blanket update to add the name of the file to the title after cleaning it up a bit.

    i have the following code so far:

    **

    protected void GetMedia(Media[] meds)
            {
                foreach (Media m in meds)
                {
                    String mType = "";
                    //THIS WILL CHECK WHETHER THE ITEM IS A FOLDER OR A FILE
                    if (!m.HasChildren)
                    //NOW WE NEED TO FILTER THE MEDIA TYPES
                        mType = m.getProperty("umbracoExtension").Value.ToString();
                    //CHECK IF THE ITEM IS A PDF
                    if (mType == "pdf")
                        //SET THE DOCUMENT TITLE TO EQUAL THE NAME
                        Response.Write("<hr>::" + "<br />::" + m.Id + "::<br />::" + m.Text + "::<br />::" + mType + "::<br />::" + m.sortOrder);
    
                    if (m.HasChildren)
                        GetMedia(m.Children);
                }
            }

    **

    so far so good, i get a list of all pdf items in the media section, with some of their proerties/attributes.

    BUT i have added a property 'fileTitle' to the 'file' media type, and i have tried accessing this with:

    Type = m.getProperty("umbracoExtension").Value.ToString();

    but this is throwing an error.

    Can anybody help me out, i need to know:

    1. how do i access the additional properties?
    2. how do i update them?

  • Kevin Farrow 46 posts 67 karma points
    Mar 20, 2010 @ 18:39
    Kevin Farrow
    0

    you should be able to access the properties using:

    string fileType = m.getProperty("fileType").Value.ToString();

    Hope that helps... RDNZL

  • Fergus Davidson 309 posts 586 karma points
    Mar 25, 2010 @ 09:39
    Fergus Davidson
    0

    thanks RDNZL.

    i don't know what i was doing wrong, but it all seems to work now.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies