Example #1
0
        /// <summary>
        /// Gets the media Id by URL.
        /// </summary>
        /// <param name="url">The URL to get the media id from.</param>
        /// <returns>Returns the media Id.</returns>
        public static int GetMediaIdByUrl(string url)
        {
            if (!string.IsNullOrWhiteSpace(url))
            {
                var mediaPath = IOHelper.ResolveUrl(SystemDirectories.Media);
                if (url.StartsWith(mediaPath) && url.Length > mediaPath.Length)
                {
                    var parts = url.Substring(mediaPath.Length).Split(new[] { '/', '-' }, StringSplitOptions.RemoveEmptyEntries);
                    int propertyId;

                    if (parts.Length > 1 && int.TryParse(parts[1], out propertyId))
                    {
                        return(Cms.GetContentIdByPropertyId(propertyId));
                    }
                }
            }

            return(uQuery.RootNodeId);
        }
Example #2
0
 /// <summary>
 /// Gets the unique id of a node.
 /// </summary>
 /// <param name="nodeId">The node id.</param>
 /// <returns>Returns the unique id of a node.</returns>
 public static string GetUniqueId(int nodeId)
 {
     return(Cms.GetUniqueId(nodeId));
 }
Example #3
0
 /// <summary>
 /// Gets the unique id of a media node.
 /// </summary>
 /// <param name="mediaId">The media id.</param>
 /// <returns>Returns the unique id of a media node.</returns>
 public static string GetUniqueId(int mediaId)
 {
     return(Cms.GetUniqueId(mediaId));
 }