Copied to clipboard

Flag this post as spam?

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


  • Simon Goldsmith 14 posts 33 karma points
    Nov 20, 2013 @ 13:11
    Simon Goldsmith
    0

    Getting property values from tab?

    I have the following code that gets all the properties of a specified tab, but I do not know how to access the values of said properties???

    @{
    
                            var docType = umbraco.cms.businesslogic.web.DocumentType.GetByAlias("Homepage");
                            if (docType != null)
                            {
                                foreach (var tab in docType.getVirtualTabs)
                                {
                                    //only get properties for 'Hero Carousel' tab
                                    if (tab.Caption == "Hero Carousel")
                                    {
                                        foreach (var propertyType in tab.PropertyTypes)
                                        {
                                           string currentPageProperty = "";
                                           if(propertyType.Alias.Contains("carouselImage"))
                                           {
                                                currentPageProperty = "CurrentPage." + @propertyType.Alias.ToString();
                                           }
                                           if (CurrentPage.HasValue(@propertyType.Alias.ToString()) && currentPageProperty.ToString() != null)
                                            {
                                                <a href="#" class="img">@currentPageProperty</a>                                                
                                            }
    
                                            //<a href="#" class="img"><img src="@Umbraco.TypedMedia(int.Parse(@currentPageProperty)).Url"  alt="@Umbraco.TypedMedia(int.Parse(@currentPageProperty)).Name"/></a>
                                        }
                                    }
                                }
                            }
                        }
    
  • Charles Afford 1163 posts 1709 karma points
    Nov 26, 2013 @ 22:09
    Charles Afford
    0

    Hi, do you know all of the alias you need?

    Are you using MVC or web forms?

    You should be able to just create a new node

    DynamicNode node = new DynamicNode(Node.GetCurrent().id);

    if(node.hasProperty("yourpropertyalias")

    {

    node.getProperty("yourpropertyalias");

    }

    Just keep passing in your the propertys you need.  Hope this helps.  Charlie :)

Please Sign in or register to post replies

Write your reply to:

Draft