Tuesday, July 19, 2011

Save time and wow your friends with this cool Dynamic Converter hack

If you ever wanted to add logic to the output of dynamic converter - this article will give you the best "gotcha" in a longest time. In the next few minutes I'll show you how to conditionally display parts of a dynamically converted word document - based on ... the query string parameters!

Yeah, you won't find this in the manual, but  if you think about it - its a really simple and natural thing to do....

Let’s imagine that you have a bunch of word documents that contain a summary and the full story (or English and French sections) and you only want to display the first sections in your  summary page, and full docs on the story page. And you don’t want to have to store your summary in a separate word document. 

Using just one document will avoid duplicated content and make it much easier and intuitive to update - all content in one place.

To show you exactly how to do it I've setup  a simple template with a region and inserted a dynamic converted word document in it. 

What I want to see happening is this:
  • When I don’t send anything on the query string or send "show=0" - I only want to see the summary or my "regular content" section (See screenshot below)

  • When I send "show=1" on the query string - I want to see my entire document (See screenshot below)

So how do I make my converted word document "that dynamic"?

Well, I can embed some java script in the document as hidden text but this is really messy and fragile. Contributors will have to look at this every day and will soon begin to hate you to a degree that actually affects your digestion system. Don’t do that!

So here's a better option. Let me give you a little hint - dynamic converter converts native application content to.... HCSTs!

Yes, you can simply use iDoc in your dynamic converter template!

Here's how:
  • In your word document create a new paragraph style. Formatting and the style name are not important for what we're trying to accomplish here
  • Apply your new style to the section that you want to dynamically show and hide
  • Save your document and check it into the Content Server.
  • Fire up your Dynamic converter Template Editor and click Element Setup on the right
  • Create a Dynamic converter element (on the Elements tab) and a new style (On the Styles tab)
  • Now match them up (Below is a screenshot showing you how you can map a Word Style called "Image Aligned Left" to a new element called imgAlignedLeft)

  • Go back to the Elements tab and select the element you've just created and mapped
  • Click Properties and go to HTML Tag tab
  • See screenshot below for a sample of how you can add iDoc script to hide your section based on the value from the query string!

Oh, but  what if you want to use other styles in your story and cannot apply your new style to an entire section?

Well, how about a pair of styles? Call the first one "Begin Body" and only specify a custom tag before the content. The other one will be the "End Body" and use the <$endif$> as its custom tag after the content

There  you have it

Really simple if you think about it! Using the if statement as a custom before tag for the element! That's it - entire solution fits in just 8 words :)

Hope you enjoyed this neat and powerful hack. And remember, if you ever need a hand with your UCM project, task at hand, training, support or simply an independent third party opinion - we're one email away. Just shoot us a quick note at contact at stellentExperts dot com. You'll be glad you did, just like a lot of  folks in these companies...

Oh, and we don’t have any sales people working here so after you do contact us - no one will be harassing you in the weeks to come - guaranteed!


1 comment:

  1. we are new to site studio,Oracle UCM and we need help from you regarding Site Studio localization. We are using Site Studio 11g, we need to develop website in two languages English and Arabic. Please can you give us some sample code regarding Site Studio language conversion and step by step process of localization.Site structure which we have created in Site studio 11g is:

    Uni home

    1. Uni_home (Primary Layout Page) main page of the site
    2. Uni_innerpage (Secondary Layout Page) all other pages of the site uses this layout page.

    It contains one header image, a static list for sub menus or right page navigation and one WYSIWYG contribution for main body content


     about University
    • uni_innerpage (used as primary page)
    On primary page a static list is placed that contains sub menus and one Contribution region with WYSIWYG that contains main body content. Each sub menu in primary page links to a content file that is being targeted to the main content contribution region of secondary page of the same section.
    Like :
    About University
    Strategic plans
    • uni_inner page (used as secondary page)

     administration
     colleges
     library
     deanship etc..

    All sections follow the same structure.

    And now we have to implement localization or multilingual process so we need some help.


    Vijay Kumar