Guest User

Untitled

a guest
Dec 15th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. @using System;
  2. @using System.Linq;
  3. @using umbraco.BusinessLogic;
  4. @using umbraco.cms.businesslogic.web;
  5.  
  6.  
  7.  
  8. @{  
  9.    
  10.     int pageId = umbraco.presentation.UmbracoContext.Current.PageId.Value;
  11.  
  12.     Document doc = new Document(pageId);
  13.  
  14.     var properties = doc.GenericProperties;
  15.  
  16.     var slideshowProperties = properties.Where(x => x.PropertyType.TabId == 9).ToList();
  17.  
  18.     var newprop = slideshowProperties.GroupBy(x => x.PropertyType.Alias.Substring(0, 2));
  19.  
  20.     Dictionary<String, String> PropDictionary = new Dictionary<String, String>();
  21.  
  22.  
  23.     foreach (var p in newprop)
  24.     {
  25.  
  26.         int i = 1;
  27.         String keyvalue = "";
  28.  
  29.         foreach (var c in p)
  30.         {
  31.             if (i == 1)
  32.             {
  33.                 var key = c.Value.ToString();
  34.                 PropDictionary.Add(key, null);
  35.                 keyvalue = key;
  36.             }
  37.  
  38.             if (i == 2)
  39.             {
  40.                 if (PropDictionary.ContainsKey(keyvalue))
  41.                 {
  42.                     PropDictionary[keyvalue] = c.Value.ToString();
  43.                 }
  44.             }
  45.  
  46.             i++;
  47.         }
  48.  
  49.     }
  50.              
  51.     foreach (var key in PropDictionary)
  52.     {
  53.                  <p>@key.Key</p>
  54.                  <p>@key.Value</p>
  55.     }
  56. }
Add Comment
Please, Sign In to add comment