i have a scenerion to make a table that is given below..
i have a document type named packages.. that contains a list of property
Maximum Number Of Nodes, Time, Price, Type etc.
and these are the content type..
Trial , Academic, Basic, standard
to create the table i have to loop through the property values and also the name.. i can get the values..
but here i need also the property names.. how can i achieve this..
var content = contentService.GetById(1234); foreach(var property in
content.Properties){
string alias = property.Alias;
object value = property.Value;
Guid version = property.Version; }
it is possible to get alias by doing this but i don't want to hardcode the ID
var docType = DocumentType.GetByAlias(umbNode.NodeTypeAlias);
foreach (var propertyType in docType.PropertyTypes)
{
var propName = propertyType.Name;
var propValue = umbNode.GetProperty(propertyType.Alias).Value;
}
You can avoid hardcoding the Id if you know from where in the tree you want to select the startnode. If you can show an example of what your tree looks like, what each node's document type is and on what page you want to show this information is then that would help.
get property names and alias of a document type
i have a scenerion to make a table that is given below..
i have a document type named packages.. that contains a list of property
and these are the content type..
to create the table i have to loop through the property values and also the name.. i can get the values.. but here i need also the property names.. how can i achieve this..
it is possible to get alias by doing this but i don't want to hardcode the ID
any better solution... thanks in advance
Hi Sadid,
Kinldy check the below
Hope this will help you.
Regards,
Mehul Gajjar.
Just a huge, huge warning: both of these methods avoid the cache and will grab data from the database each time, this is killing for performance. Please consider using
TypedContent
, see reference docs: https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/You can avoid hardcoding the Id if you know from where in the tree you want to select the startnode. If you can show an example of what your tree looks like, what each node's document type is and on what page you want to show this information is then that would help.
is working on a reply...