8

I just came across these built in functions for obtaining page metadata here:

https://code.google.com/p/tridion-practice/wiki/BuiltInFunctionsForUseInHtmlTemplates For example: !GetFieldMetadata("Image")=Name: Image

I've never use them so don't have an example to work with and the guesses i've made so far to use this function hasn't worked.

My page has a metadata schema with the field 'page_title', so i'm trying to render this using:

@@GetFieldMetadata("page_title")@@

But this doesn't work. I've tried the usual varieties "Page.Metadata.page_title", "Page.Metadata.Fields.page_title"

If anyone one has a quick solution, great, failing that i'm going back over to to a c# tbb :)

Update: Added a comment to Nick's comment below.

  • You can just do @@Metadata.page_title@@. Not sure why you'd need a function for that. – Nickoli Roussakov Apr 29 '13 at 21:49
  • 2
    @NickoliRoussakov - I had forgotten and have used @@Page.Metadata.page_title@@ - i'd still like to know how to get the GetFieldMetadata function to work – johnwinter Apr 29 '13 at 21:50
  • 1
    Interesting! +1 for wanting to know if/what @@GetFieldMetadata("page_title")@@ adds over @@Page.Metadata.page_title@@. – Chris Morgan Apr 29 '13 at 22:00
11

This method doesn't get a metadata field... it gets a field's metadata. For a Component with a multi-lined text field of "BodyText"...

@@GetFieldMetadata("BodyText")@@

Would return the following output:

Height: 10
DefaultValue: 
Name: BodyText
Description: BodyText
CustomUrl: 
MinOccurs: 0
MaxOccurs: 1

The function contains an optional 2nd argument which is a boolean that tells it whether or not the field is a metadata field or not, so for your example, you would want to do something along the lines of:

@@GetFieldMetadata("page_title", true)@@

The Default Dreamweaver Page Design and Default Dreamweaver Component Design templates also have a good example of putting this method to use Hope that helps!

| improve this answer | |
  • thanks alex - i couldn't see the wood for the trees. that's interesting, i didn't know that was possible with dwt. i certainly can't imagine a use-case for it but always good to know. – johnwinter Apr 30 '13 at 13:49
  • Use cases could be for testing and CMS designs! Walter van der Heiden had a post describing how he'd "inject" information (e.g. TCM urls) into just Staging markup for testing. I'm envisioning ways to create a page/content type breakdown auto-magically by adding schema and template name directly to markup. I believe the default templates use the title attribute to make a field's metadata look like a tooltip (based on your browser's functionality). – Alvin Reyes Apr 30 '13 at 14:49
  • hi alvin, i get you - say a user doesn't enter a value it could display something in a certain scenario – johnwinter Apr 30 '13 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.