I'm using SDL Tridion version 2013. Can anyone provide sample code to pull page metadata contents using CoreService?
-
There's no 2012 version. Please be more specific in what you want to do. Do you want to read page metadata? If so, through which interface - CoreService, or TOM.NET?– Andrey MarchukJul 23, 2013 at 13:59
-
Apologies. ver 2013. Using CoreService.– RickJul 23, 2013 at 14:31
-
3@Rick, welcome to the Tridion community. Please have a look at tridion.stackexchange.com/help/how-to-ask. It is customary to demonstrate your effort in researching the answer. Once you do that many of us will be happy to help.– Nickoli RoussakovJul 23, 2013 at 14:32
3 Answers
Assuming you are using Tridion 2011/2013, Page Metadata can be read in several ways.
Templates
@@Page.Metadata.field@@
(Dreamweaver Syntax)ItemFields metaFields = new ItemFields(page.Metadata, page.MetadataSchema);
(TOM.Net)Event System
ItemFields metaFields = new ItemFields(page.Metadata, page.MetadataSchema);
(TOM.Net)Core Services
PageData page = channel.Read(pageId, new ReadOptions());
XElement xMetadata = XElement.Parse(page.Metadata);
Content Delivery
PageMetaFactory metaFactory = new PageMetaFactory(publicationId);
IPageMeta pageMeta = metaFactory.GetMetaByUrl(pageUrl);
CustomMeta customMeta = pageMeta.CustomMeta;
-
-
The fieldname is PricingPageType. I've tried Page.metadata.Fields.PricingPageType,Metadata.Fields.PricingPageType,Page.Fields.PricingPageType, Page.PricingPageType with no success.– RickJul 23, 2013 at 18:57
-
-
I usually use the Core Service fields helper when accessing fields and metafields via core service. Creates a tom-like API. code.google.com/p/tridion-practice/wiki/ChangeContentOrMetadata– robrtcJul 24, 2013 at 7:11
-
Here's the new link now that this code has been moved from Google Code to GitHub: github.com/TridionPractice/tridion-practice/wiki/… Apr 17, 2019 at 12:33
If you are using Razor Mediator, this can be done fairly easily. I'd created a "debugging TBB" in razor that goes over most all of the properties accessible to you from Razor. If you were looking for a hard example with razor, it'd just be @Page.Metadata
.
If you aren't using Razor mediator, then I'd like to encourage you to start - simply because it makes a task like this very simple. If for some reason you can't, I'd defer you to the .net-based answers.
first, there is no Tridion version 2012, i think you are talking about 2011 SP1? and you can read page metadata from CoreService and TOM.NET, depending how you want to implement the third party application. let me know if you have more questions.
-
-
ok, no problem, for 2013 you can use Coreservice, which is preferred method for integrate your third party application. for coreservice reference: sdllivecontent.sdl.com if i am correct give me some score :) Jul 23, 2013 at 14:35