2

When client publish one News Component, they want to push the News to different location, include some external system.

  1. This action must be invoked when client publish the News component, so we have to use Event system.
  2. The only way to communicate with this external system is invoke its own API, push the News content inside it;
  3. It is forbidden to let this external system call Tridion envrionment;

What we do right now is add one Post Publish Event. When we publish the News component, we catch it and push it to this external system.

The trick part is this News Component contains one Multimedia Image, and inside the Component parameter, it only contains the Multimedia Image's TCM URI instead of the real URL.

Inside the API, it looks like below: OnComponentPublishPost(Component component, PublishEventArgs eventArgs, EventPhases eventPhase). We can find the Component object, but it is not the rendered result. It only contains the image TCM ID instead of the really image URL.

Does anyone know how can we get the real render result or the image's real URL? Thanks.

Best regards, Qiang

1
  • 1
    You mention: "when client publish the News component, so we have to use Event system." This is not true. You can (and should) use a Storage Extension which will be triggered when you publish something. The event system is the wrong extension point in your case. Commented Feb 26, 2014 at 19:18

2 Answers 2

2

There are ways to access the rendered result in the CMS, but if you want to place the result of the rendered result in other repository (for archiving purposes for instance), the area you typically extend is the deployer/broker

An approach you could take is Publish the News together with the Binary as a Dynamic Component Presentation.

You can extend the ComponentPresentationDeploy (Deployer area) for identify that the component presentation you are publishing has a component based on the schema "News".

If that is the case, interact with this extension with the external system and send the content of the Dynamic Component Presentation there, which is at the end the result of the render.

Unless there is any restriction in communication between the content delivery and the external system, I would suggest to do here instead than in the Event.

Also, keep in mind that the binary will be deployed into the Content Delivery, check if is fine to refer from the News that will be displayed in the final system the binary that is in your delivery (You can just pre the domain to the binary reference) or if you have to send the binary to the external system.

Just mention that you can calculate the path of the binary during publishing time. There is a property that allows you to do that in any C# Template Building Block if you know the tcm of the binary (you can parse the Output Package and find that)

One more thing I suggest is think what to do if the user un-publishes the news. You should extend also the ComponentPresentationUndeploy.

2
  • 1
    Thanks Miguel, since the background requirement is very complex, I tried to simply it and updated my questions.
    – qchen01
    Commented Feb 26, 2014 at 19:15
  • Updated the answer, didn't have enough characters to add that as a comment :)
    – Miguel
    Commented Feb 26, 2014 at 19:32
1

In the Event System you're getting only the component as input. It is not part of the rendering process, and it sounds like you're looking for a ComponentPresentation. In layman's terms, you're using the wrong extension point.

On the CM side creating a regular Template Building Block should be more appropriate because rendering is triggered when someone is publishing. You can also check the context of publishing in a TBB (to differentiate between rendering in TemplateBuilding or Preview modes).

Using a Storage Extension is also appropriate for the use case you describe. See Will's post and example of how he did a similar thing for CDN integration: http://sdltridionworld.com/articles/sdltridion2011/tutorials/cdn_integration.aspx and http://www.tridiondeveloper.com/some-thoughts-on-cmscdn-integration.

If you are adamant about doing it CM side and not using either of the above, then you're entering somewhat uncharted waters. What you can try to do is re-create the CP in the Event System by running it against the "News" Component Template:

        BuiltInFunctions f = new BuiltInFunctions();
        string renderedCp = f.RenderComponentPresentation(component.Id.ToString(), "tcm:1-2-32");

Though, I'm not sure the above will work in the context of the Event System. I've only tested it as far as compiling.

Another way you can grab the rendered component presentation is actually by using a Custom Renderer as discussed here: https://stackoverflow.com/questions/14655972/whats-a-non-delivery-custom-renderer (warning: I don't know if anyone has ever used one though, but it exists).

2
  • Hi Nickoli, where can I find the BuiltInFunctions class? Should I reference any DLL inside my project to use it?
    – qchen01
    Commented Feb 26, 2014 at 19:24
  • It's inside Tridion.ContentManager.Templating.Expression (Tridion.ContentManager.Templating.dll). I seriously advise you against doing it this way. See my updated answer. Commented Feb 26, 2014 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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