Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access a component's fields from a custom deployer

Tags:

tridion

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?

like image 370
ajwhitehead88 Avatar asked May 09 '12 12:05

ajwhitehead88


2 Answers

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.

like image 118
Nuno Linhares Avatar answered Oct 20 '22 19:10

Nuno Linhares


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.

like image 33
Ram G Avatar answered Oct 20 '22 20:10

Ram G