Developer forum

Forum » Development » Dynamicweb.Content.Files.Metadata.Meta - How to use

Dynamicweb.Content.Files.Metadata.Meta - How to use

Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

I am trying to figure out how to use the namespace Dynamicweb.Content.Files.Metadata.Meta for getting metadata from metafields that are set inte File Manager.

Exampel:

I have configured a metafield called "DocumentName". 

I have added that field to a file in File Manager. 

Now I want to get that value in a razor template where I know the path to the file. 

I thought I could do something like below, but that does not give me anything. 

Any suggestions?

 

var metadata = new Dynamicweb.Content.Files.Metadata.Meta {File = pathToFileUrl };

metadata.GetValue("DocumentName")

Regards / Aki

 


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Aki,

You should be able to do something like this:

Dynamicweb.Content.Files.Metadata.Meta metadata = Dynamicweb.Content.Files.Metadata.EditorFactory.GetMetadataForFile(filePath);

if (metadata != null)
{
    string documentName = metadata.GetValue("DocumentName");
}

Best regards,
Morten

Votes for this answer: 1
 
Aki Ruuskanen
Aki Ruuskanen
Reply

Perfect, thanks! yes

 

You must be logged in to post in the forum