Copied to clipboard

Flag this post as spam?

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


  • Nico Fortin 5 posts 25 karma points
    Nov 21, 2010 @ 20:30
    Nico Fortin
    0

    Complete API Documentation

    Hi everyone,

       I'm looking (since about an hour) for an API reference of umbraco. I've been able to guess the media section (umbraco.cms.businesslogic.media) from a .NET usercontrol but, now I'm stuck for getting the content items.

       Anyone have a suggestion ?

    Thanks

    Nico

  • jc 64 posts 101 karma points
    Nov 21, 2010 @ 20:51
  • Nico 16 posts 37 karma points
    Nov 22, 2010 @ 01:33
    Nico
    0

    This looks helpful but, what gives me the basic path to the content items tree... Do I missed something ?

     

  • Nico Fortin 5 posts 25 karma points
    Nov 22, 2010 @ 23:56
    Nico Fortin
    0

    Anybody knows how to access to root element of the content section within aa ASP.NET usercontrol ?

    Thanks in advance for your answers.

     

  • jc 64 posts 101 karma points
    Nov 23, 2010 @ 02:28
    jc
    0

    If i add a macro parameter and pass a value of -1, which should be the root, I get an error. When I pass in the ID of a folder in the media section I can get the contents of that folder. I've never tried getting the root of the media folder so I'm not sure if I'm doing something wrong or if this is by design. BTW, I had to change one line from:

    <xsl:param name="mediafolder" select="/macro/mediaFolder/Folder/@id" />

    to

    <xsl:param name="mediafolder" select="/macro/mediaFolder" />

    The error I was getting was "No media is maching '-1'", which it looks like this will show up if an exception is thrown in the GetMedia method.

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    Nov 23, 2010 @ 14:36
    Robert Foster
    0

    A value of -1 represents a "null" node.  in other words, there is no node with an id of -1.  Perhaps you could describe exactly what you are trying to achieve and post the code?

     

  • jc 64 posts 101 karma points
    Nov 23, 2010 @ 14:59
    jc
    0

    I was trying to select the root of the media section. I placed a Media Picker data type on my document type. When I selected the media section root and then saved/published, the value it saved was -1. Is there a way to get directly to the root of the media section with umbraco.library:GetMedia?

  • Nico Fortin 5 posts 25 karma points
    Nov 23, 2010 @ 15:04
    Nico Fortin
    0

    Hi,

    For my case, I was talking about the C# API, something like Media m = Media.GetRoot(); (I don't have my code on sight right now).

    Is there a documentation on this ? What class should I call to get the root of the Content section ?

  • Nico Fortin 5 posts 25 karma points
    Nov 23, 2010 @ 23:27
    Nico Fortin
    0

    Hi,

    just to clarify, the exact call I'm looking for is like Media.GetRootMedias() but, for the Content tree.

    Anybody has a suggestion ?

  • Claus Jensen 49 posts 157 karma points hq
    Nov 24, 2010 @ 02:59
    Claus Jensen
    0

    Well..

    Node n = new Node(-1)

    will give you the root node (named 'Content' when browsing in the cms).

    I assume you're trying to locate something in the content tree - from the root node you can travel down the tree and find whatever you need by using for example:

    Node n = new Node(-1).Children.OfType<Node>().Where(n => n.NodeTypeAlias == "SomeDocumentType").First()

  • Claus Jensen 49 posts 157 karma points hq
    Nov 24, 2010 @ 03:02
    Claus Jensen
    0

    So yeah it's basicly done a bit different than what you do with Media.GetRootMedias(), but it's the equivalent function for getting root content node...

  • jc 64 posts 101 karma points
    Nov 24, 2010 @ 03:59
    jc
    0

    This will work in a user control, but I'd still like to know if this can be done with umbraco.library in an XSLT file:

    StringBuilder sb = new StringBuilder();
    umbraco.cms.businesslogic.media.Media[] docs = new umbraco.cms.businesslogic.media.Media(-1).Children;
    foreach (umbraco.cms.businesslogic.media.Media dd in docs)
    {
        sb.Append(dd.Id.ToString() + " : " + dd.Text + "<br />");
    }
    litOutput.Text = sb.ToString();
  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    Nov 24, 2010 @ 05:49
    Robert Foster
    0

    When you create a new Media or Content object using new Media(-1) it looks in the database table umbracoNode.  using -1 retrieves the Master Root Node for the Content object type.  The first call to Children on the returned object queries the database for all nodes that have the Id as their parent.  The Media type specifies it's own Object Type Id, so Children retrieve only Media items in this context.

    however, the default umbraco.library.GetMedia() method returns an invalid node message in the XML because the Object Type Id of the Media item doesn't match what was retrieved from the database (which is a Content Object Type).

    So with the current umbraco.library there is no way to get the Root Media items in Xslt.  However, you could create your own Xslt extension library to expose the Media.GetRootMedias() method which will essentially do what you want...

     

  • Nico 16 posts 37 karma points
    Nov 27, 2010 @ 17:58
    Nico
    0

    Hi,

       this is what I was looking for. Thanks to everybody.

Please Sign in or register to post replies

Write your reply to:

Draft