Get TabId by Url

Sep 18, 2015 at 3:55 PM
I have a Content Type called link that has a Name and PageLink as properties. What I'm trying to do in my template is, as I'm looping through the list of objects, if one of them happens to be the page that I'm on I want to add a css class so that it shows as "active" so the link gets highlighted. In the template the PageLink property returns a string for the url. Is there anyway to get the TabId from the Entity object in the template so that I can compare it to the ActiveTab to see if it's a match?
Sep 18, 2015 at 4:34 PM
Does not appear to be returned from the entity

https://github.com/2sic/eav/blob/master/ToSic.Eav/Interfaces/IEntity.cs

Maybe Daniel has an idea of how to tackle this
Coordinator
Sep 21, 2015 at 6:43 AM
Basically the answer is yes you can - but not through the AsDynamic version which simplifies too much.

If you go through AsEntity(original).GetBestValue("FieldName", false) --> something like this should do it. I think that the second optional parameter disables the link-resolution.

As an alternative you can go even deeper, so
AsEntity(original).Attributes["fieldname"].Values <- this is a list of possible values assigned to different languages.
Sep 21, 2015 at 6:21 PM
Thanks for the idea. As a quick and dirty method, I just used razor to get the current page url from and then compared it to the value from the AsDynamic entity to see if the urls match. If they do then I apply the class to make it the active link
@{  
    string aurl = DotNetNuke.Entities.Tabs.TabController.CurrentPage.FullUrl; 
}
<li class="sc-element @(@Content.Link == aurl ? "active" : "")">