17

I'm trying to create a custom deployer in Tridion 2011 SP1 that can index a component to a solr instance once published. Everything is working fine but I've come across a bit of a problem with the way it indexes the components fields.

I can access the meta data fields okay by using the Component.getCustomMeta() method and parsing the XML. Accessing the normal fields however does not seem to be possible without reading in the file that is being output and parsing the output. This is not entirely feasible as the markup may change and it seems to be a long way around doing what should (hopefully) be a simple thing.

I've had a trawl through the docs and there doesn't seem to be anything available to get the field values so am I at a loss here and will need to parse the output or am I missing something somewhere?

ajwhitehead88
  • 428
  • 3
  • 9

2 Answers2

12

Content fields are not exposed as such on the delivery side, content is exposed as, not surprisingly, "content".

If you really need the fields, you need to:

  1. Produce a "parseable" output for your component presentations
  2. Parse the component presentations as they get published.

Look at implementations like DD4T for similar approaches.

In short - you cannot do it, because Tridion does not expose it Out of the Box. The only way to do it is by changing the content output format through a template.

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
4

We have done an alternative workaround to achieve for the similar requirement. One down side with the implementation is extra rendering of Component Presentations in XML and duplicate of xml storage in broker.

Here is what we have done:

  1. Created a Dynamic CT (XML representation of content) GetComponentAsXML and mapped to all schemas
  2. All the Page Templates has a C# TBB that looks up the content that we need to push to SOLR
  3. C# TBB does the RenderComponentPresentation with above Dynamic CT GetComponentAsXML, this pushes the XML (engine.RenderComponentPresentation(component.Id, componentTemplateURI)
  4. Deployer now gets the content in xml format, in addition to the other type of component presentations (like ascx, emebedded on page etc..)

Hope this information helps.

Ram G
  • 4,829
  • 1
  • 16
  • 26
  • Thanks Ram, this does look like a reasonable way to go. I'm currently looking into the events system to bind an event handler for the publish/unpublish of pages and dynamic CPs. It seems to be going okay but if it fails then I'll look into something like what you have described – ajwhitehead88 May 10 '12 at 13:19